SafeToast.smali

.class public Lcom/cleanmaster/util/SafeToast;
.super Ljava/lang/Object;
.source "SafeToast.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/cleanmaster/util/SafeToast$TN;
    }
.end annotation


# static fields
.field static final TAG:Ljava/lang/String; = "SafeToast"


# instance fields
.field final mContext:Landroid/content/Context;

.field mDuration:I

.field mNextView:Landroid/view/View;

.field mSysToast:Landroid/widget/Toast;

.field final mTN:Lcom/cleanmaster/util/SafeToast$TN;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 4

    .prologue
    .line 77
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 78
    new-instance v0, Landroid/util/DisplayMetrics;

    invoke-direct {v0}, Landroid/util/DisplayMetrics;-><init>()V

    .line 79
    iput-object p1, p0, Lcom/cleanmaster/util/SafeToast;->mContext:Landroid/content/Context;

    .line 80
    new-instance v0, Landroid/widget/Toast;

    iget-object v1, p0, Lcom/cleanmaster/util/SafeToast;->mContext:Landroid/content/Context;

    invoke-direct {v0, v1}, Landroid/widget/Toast;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mSysToast:Landroid/widget/Toast;

    .line 81
    new-instance v0, Lcom/cleanmaster/util/SafeToast$TN;

    invoke-direct {v0}, Lcom/cleanmaster/util/SafeToast$TN;-><init>()V

    iput-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    .line 82
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iget-object v1, p0, Lcom/cleanmaster/util/SafeToast;->mSysToast:Landroid/widget/Toast;

    invoke-virtual {v1}, Landroid/widget/Toast;->getYOffset()I

    move-result v1

    iput v1, v0, Lcom/cleanmaster/util/SafeToast$TN;->mY:I

    .line 83
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iget-object v1, p0, Lcom/cleanmaster/util/SafeToast;->mSysToast:Landroid/widget/Toast;

    invoke-virtual {v1}, Landroid/widget/Toast;->getGravity()I

    move-result v1

    iput v1, v0, Lcom/cleanmaster/util/SafeToast$TN;->mGravity:I

    .line 84
    return-void
.end method

.method public static makeText(Landroid/content/Context;II)Lcom/cleanmaster/util/SafeToast;
    .registers 4
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/content/res/Resources$NotFoundException;
        }
    .end annotation

    .prologue
    .line 240
    invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

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

    move-result-object v0

    invoke-static {p0, v0, p2}, Lcom/cleanmaster/util/SafeToast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Lcom/cleanmaster/util/SafeToast;

    move-result-object v0

    return-object v0
.end method

.method public static makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Lcom/cleanmaster/util/SafeToast;
    .registers 7

    .prologue
    .line 214
    new-instance v1, Lcom/cleanmaster/util/SafeToast;

    invoke-direct {v1, p0}, Lcom/cleanmaster/util/SafeToast;-><init>(Landroid/content/Context;)V

    .line 216
    const-string v0, "layout_inflater"

    .line 217
    invoke-virtual {p0, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/view/LayoutInflater;

    .line 218
    const v2, 0x7f04010c

    const/4 v3, 0x0

    invoke-virtual {v0, v2, v3}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;)Landroid/view/View;

    move-result-object v2

    .line 219
    const v0, 0x102000b

    invoke-virtual {v2, v0}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/TextView;

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

    .line 222
    iput-object v2, v1, Lcom/cleanmaster/util/SafeToast;->mNextView:Landroid/view/View;

    .line 223
    iput p2, v1, Lcom/cleanmaster/util/SafeToast;->mDuration:I

    .line 225
    return-object v1
.end method


# virtual methods
.method public cancel()V
    .registers 3

    .prologue
    .line 106
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    invoke-virtual {v0}, Lcom/cleanmaster/util/SafeToast$TN;->hide()V

    .line 107
    invoke-static {}, Lcom/cleanmaster/util/SafeToastManager;->getInst()Lcom/cleanmaster/util/SafeToastManager;

    move-result-object v0

    iget-object v1, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    invoke-virtual {v0, v1}, Lcom/cleanmaster/util/SafeToastManager;->cancelToast(Lcom/cleanmaster/util/IToastCallback;)V

    .line 108
    return-void
.end method

.method public getDuration()I
    .registers 2

    .prologue
    .line 138
    iget v0, p0, Lcom/cleanmaster/util/SafeToast;->mDuration:I

    return v0
.end method

.method public getGravity()I
    .registers 2

    .prologue
    .line 187
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iget v0, v0, Lcom/cleanmaster/util/SafeToast$TN;->mGravity:I

    return v0
.end method

.method public getHorizontalMargin()F
    .registers 2

    .prologue
    .line 160
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iget v0, v0, Lcom/cleanmaster/util/SafeToast$TN;->mHorizontalMargin:F

    return v0
.end method

.method public getVerticalMargin()F
    .registers 2

    .prologue
    .line 167
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iget v0, v0, Lcom/cleanmaster/util/SafeToast$TN;->mVerticalMargin:F

    return v0
.end method

.method public getView()Landroid/view/View;
    .registers 2

    .prologue
    .line 123
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mNextView:Landroid/view/View;

    return-object v0
.end method

.method public getXOffset()I
    .registers 2

    .prologue
    .line 194
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iget v0, v0, Lcom/cleanmaster/util/SafeToast$TN;->mX:I

    return v0
.end method

.method public getYOffset()I
    .registers 2

    .prologue
    .line 201
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iget v0, v0, Lcom/cleanmaster/util/SafeToast$TN;->mY:I

    return v0
.end method

.method public setDuration(I)V
    .registers 2

    .prologue
    .line 130
    iput p1, p0, Lcom/cleanmaster/util/SafeToast;->mDuration:I

    .line 131
    return-void
.end method

.method public setGravity(III)V
    .registers 5

    .prologue
    .line 176
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iput p1, v0, Lcom/cleanmaster/util/SafeToast$TN;->mGravity:I

    .line 177
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iput p2, v0, Lcom/cleanmaster/util/SafeToast$TN;->mX:I

    .line 178
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iput p3, v0, Lcom/cleanmaster/util/SafeToast$TN;->mY:I

    .line 179
    return-void
.end method

.method public setMargin(FF)V
    .registers 4

    .prologue
    .line 152
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iput p1, v0, Lcom/cleanmaster/util/SafeToast$TN;->mHorizontalMargin:F

    .line 153
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    iput p2, v0, Lcom/cleanmaster/util/SafeToast$TN;->mVerticalMargin:F

    .line 154
    return-void
.end method

.method public setText(I)V
    .registers 3

    .prologue
    .line 248
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mContext:Landroid/content/Context;

    invoke-virtual {v0, p1}, Landroid/content/Context;->getText(I)Ljava/lang/CharSequence;

    move-result-object v0

    invoke-virtual {p0, v0}, Lcom/cleanmaster/util/SafeToast;->setText(Ljava/lang/CharSequence;)V

    .line 249
    return-void
.end method

.method public setText(Ljava/lang/CharSequence;)V
    .registers 4

    .prologue
    .line 256
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mNextView:Landroid/view/View;

    if-nez v0, :cond_c

    .line 257
    new-instance v0, Ljava/lang/RuntimeException;

    const-string v1, "This Toast was not created with Toast.makeText()"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 259
    :cond_c
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mNextView:Landroid/view/View;

    const v1, 0x102000b

    invoke-virtual {v0, v1}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/TextView;

    .line 260
    if-nez v0, :cond_21

    .line 261
    new-instance v0, Ljava/lang/RuntimeException;

    const-string v1, "This Toast was not created with Toast.makeText()"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 263
    :cond_21
    invoke-virtual {v0, p1}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 264
    return-void
.end method

.method public setView(Landroid/view/View;)V
    .registers 2

    .prologue
    .line 115
    iput-object p1, p0, Lcom/cleanmaster/util/SafeToast;->mNextView:Landroid/view/View;

    .line 116
    return-void
.end method

.method public show()V
    .registers 4

    .prologue
    .line 90
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mNextView:Landroid/view/View;

    if-nez v0, :cond_d

    .line 91
    new-instance v0, Ljava/lang/RuntimeException;

    const-string/jumbo v1, "setView must have been called"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 94
    :cond_d
    iget-object v0, p0, Lcom/cleanmaster/util/SafeToast;->mTN:Lcom/cleanmaster/util/SafeToast$TN;

    .line 95
    iget-object v1, p0, Lcom/cleanmaster/util/SafeToast;->mNextView:Landroid/view/View;

    iput-object v1, v0, Lcom/cleanmaster/util/SafeToast$TN;->mNextView:Landroid/view/View;

    .line 97
    invoke-static {}, Lcom/cleanmaster/util/SafeToastManager;->getInst()Lcom/cleanmaster/util/SafeToastManager;

    move-result-object v1

    iget v2, p0, Lcom/cleanmaster/util/SafeToast;->mDuration:I

    invoke-virtual {v1, v0, v2}, Lcom/cleanmaster/util/SafeToastManager;->enqueueToast(Lcom/cleanmaster/util/IToastCallback;I)V

    .line 98
    return-void
.end method