.class public Lcom/tcn/tools/lang/CustomTextHelper;
.super Lskin/support/widget/SkinCompatHelper;
.source "CustomTextHelper.java"


# instance fields
.field private mTextContentResId:I

.field private mTextHintResId:I

.field private mTextSizeResId:I

.field final mView:Landroid/widget/TextView;


# direct methods
.method public constructor <init>(Landroid/widget/TextView;)V
    .locals 1

    .line 30
    invoke-direct {p0}, Lskin/support/widget/SkinCompatHelper;-><init>()V

    const/4 v0, 0x0

    .line 16
    iput v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextContentResId:I

    .line 17
    iput v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextSizeResId:I

    .line 19
    iput v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextHintResId:I

    .line 31
    iput-object p1, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    return-void
.end method

.method private applyTextContentResource()V
    .locals 3

    .line 53
    iget v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextContentResId:I

    invoke-static {v0}, Lcom/tcn/tools/lang/CustomTextHelper;->checkResourceId(I)I

    move-result v0

    iput v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextContentResId:I

    if-eqz v0, :cond_1

    .line 55
    iget-object v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    invoke-virtual {v0}, Landroid/widget/TextView;->getContext()Landroid/content/Context;

    move-result-object v0

    iget v1, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextContentResId:I

    invoke-static {v0, v1}, Lcom/tcn/tools/lang/SkinUtil;->getSkinText(Landroid/content/Context;I)Ljava/lang/String;

    move-result-object v0

    .line 56
    invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-nez v1, :cond_0

    .line 57
    iget-object v1, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    invoke-virtual {v1, v0}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    goto :goto_0

    .line 59
    :cond_0
    iget-object v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    invoke-virtual {v0}, Landroid/widget/TextView;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v1

    iget v2, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextContentResId:I

    invoke-virtual {v1, v2}, Landroid/content/res/Resources;->getText(I)Ljava/lang/CharSequence;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 62
    :cond_1
    :goto_0
    iget v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextSizeResId:I

    invoke-static {v0}, Lcom/tcn/tools/lang/CustomTextHelper;->checkResourceId(I)I

    move-result v0

    iput v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextSizeResId:I

    if-eqz v0, :cond_3

    .line 64
    iget-object v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    invoke-virtual {v0}, Landroid/widget/TextView;->getContext()Landroid/content/Context;

    move-result-object v0

    iget v1, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextSizeResId:I

    invoke-static {v0, v1}, Lcom/tcn/tools/lang/SkinUtil;->getSkinSize(Landroid/content/Context;I)I

    move-result v0

    if-eqz v0, :cond_2

    .line 66
    iget-object v1, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    int-to-float v0, v0

    invoke-virtual {v1, v0}, Landroid/widget/TextView;->setTextSize(F)V

    goto :goto_1

    .line 68
    :cond_2
    iget-object v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    invoke-virtual {v0}, Landroid/widget/TextView;->getResources()Landroid/content/res/Resources;

    move-result-object v1

    iget v2, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextSizeResId:I

    invoke-virtual {v1, v2}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I

    move-result v1

    int-to-float v1, v1

    invoke-virtual {v0, v1}, Landroid/widget/TextView;->setTextSize(F)V

    .line 71
    :cond_3
    :goto_1
    iget v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextHintResId:I

    invoke-static {v0}, Lcom/tcn/tools/lang/CustomTextHelper;->checkResourceId(I)I

    move-result v0

    iput v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextHintResId:I

    if-eqz v0, :cond_5

    .line 73
    iget-object v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    invoke-virtual {v0}, Landroid/widget/TextView;->getContext()Landroid/content/Context;

    move-result-object v0

    iget v1, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextHintResId:I

    invoke-static {v0, v1}, Lcom/tcn/tools/lang/SkinUtil;->getSkinText(Landroid/content/Context;I)Ljava/lang/String;

    move-result-object v0

    .line 74
    invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-nez v1, :cond_4

    .line 75
    iget-object v1, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    invoke-virtual {v1, v0}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    goto :goto_2

    .line 77
    :cond_4
    iget-object v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    invoke-virtual {v0}, Landroid/widget/TextView;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v1

    iget v2, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextHintResId:I

    invoke-virtual {v1, v2}, Landroid/content/res/Resources;->getText(I)Ljava/lang/CharSequence;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    :cond_5
    :goto_2
    return-void
.end method

.method public static create(Landroid/widget/TextView;)Lcom/tcn/tools/lang/CustomTextHelper;
    .locals 2

    .line 22
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0x11

    if-lt v0, v1, :cond_0

    .line 23
    new-instance v0, Lcom/tcn/tools/lang/CustomTextHelper;

    invoke-direct {v0, p0}, Lcom/tcn/tools/lang/CustomTextHelper;-><init>(Landroid/widget/TextView;)V

    return-object v0

    .line 25
    :cond_0
    new-instance v0, Lcom/tcn/tools/lang/CustomTextHelper;

    invoke-direct {v0, p0}, Lcom/tcn/tools/lang/CustomTextHelper;-><init>(Landroid/widget/TextView;)V

    return-object v0
.end method


# virtual methods
.method public applySkin()V
    .locals 0

    .line 84
    invoke-direct {p0}, Lcom/tcn/tools/lang/CustomTextHelper;->applyTextContentResource()V

    return-void
.end method

.method public loadFromAttributes(Landroid/util/AttributeSet;I)V
    .locals 3

    .line 36
    iget-object v0, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mView:Landroid/widget/TextView;

    invoke-virtual {v0}, Landroid/widget/TextView;->getContext()Landroid/content/Context;

    move-result-object v0

    .line 38
    sget-object v1, Lcom/tcn/tools/R$styleable;->SkinTextContentHelper:[I

    const/4 v2, 0x0

    invoke-virtual {v0, p1, v1, p2, v2}, Landroid/content/Context;->obtainStyledAttributes(Landroid/util/AttributeSet;[III)Landroid/content/res/TypedArray;

    move-result-object p1

    .line 39
    sget p2, Lcom/tcn/tools/R$styleable;->SkinTextContentHelper_android_text:I

    invoke-virtual {p1, p2}, Landroid/content/res/TypedArray;->hasValue(I)Z

    move-result p2

    if-eqz p2, :cond_0

    .line 40
    sget p2, Lcom/tcn/tools/R$styleable;->SkinTextContentHelper_android_text:I

    invoke-virtual {p1, p2, v2}, Landroid/content/res/TypedArray;->getResourceId(II)I

    move-result p2

    iput p2, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextContentResId:I

    .line 42
    :cond_0
    sget p2, Lcom/tcn/tools/R$styleable;->SkinTextContentHelper_android_textSize:I

    invoke-virtual {p1, p2}, Landroid/content/res/TypedArray;->hasValue(I)Z

    move-result p2

    if-eqz p2, :cond_1

    .line 43
    sget p2, Lcom/tcn/tools/R$styleable;->SkinTextContentHelper_android_textSize:I

    invoke-virtual {p1, p2, v2}, Landroid/content/res/TypedArray;->getResourceId(II)I

    move-result p2

    iput p2, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextSizeResId:I

    .line 45
    :cond_1
    sget p2, Lcom/tcn/tools/R$styleable;->SkinTextContentHelper_android_hint:I

    invoke-virtual {p1, p2}, Landroid/content/res/TypedArray;->hasValue(I)Z

    move-result p2

    if-eqz p2, :cond_2

    .line 46
    sget p2, Lcom/tcn/tools/R$styleable;->SkinTextContentHelper_android_hint:I

    invoke-virtual {p1, p2, v2}, Landroid/content/res/TypedArray;->getResourceId(II)I

    move-result p2

    iput p2, p0, Lcom/tcn/tools/lang/CustomTextHelper;->mTextHintResId:I

    .line 48
    :cond_2
    invoke-virtual {p1}, Landroid/content/res/TypedArray;->recycle()V

    .line 49
    invoke-virtual {p0}, Lcom/tcn/tools/lang/CustomTextHelper;->applySkin()V

    return-void
.end method
