.class public Lcom/moji/imageview/CertificateRoundImageView;
.super Landroid/widget/ImageView;
.source "CertificateRoundImageView.java"


# static fields
.field private static final c:I


# instance fields
.field private a:I

.field private final b:Landroid/content/Context;

.field private d:I

.field private e:F

.field private f:Landroid/graphics/drawable/BitmapDrawable;

.field private g:Landroid/graphics/Paint;

.field private h:Landroid/graphics/Paint;

.field private i:Landroid/graphics/BitmapShader;

.field private j:Landroid/graphics/Matrix;

.field private k:F

.field private l:Landroid/graphics/Path;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    const-string v0, "#ffffffff"

    .line 25
    invoke-static {v0}, Landroid/graphics/Color;->parseColor(Ljava/lang/String;)I

    move-result v0

    sput v0, Lcom/moji/imageview/CertificateRoundImageView;->c:I

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;)V
    .locals 1

    .line 38
    invoke-direct {p0, p1}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;)V

    const/4 v0, 0x0

    .line 23
    iput v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->a:I

    .line 27
    iput v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->d:I

    const/high16 v0, 0x3e800000    # 0.25f

    .line 28
    iput v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->e:F

    .line 39
    iput-object p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->b:Landroid/content/Context;

    .line 40
    invoke-direct {p0}, Lcom/moji/imageview/CertificateRoundImageView;->a()V

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .locals 1

    .line 44
    invoke-direct {p0, p1, p2}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    const/4 v0, 0x0

    .line 23
    iput v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->a:I

    .line 27
    iput v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->d:I

    const/high16 v0, 0x3e800000    # 0.25f

    .line 28
    iput v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->e:F

    .line 45
    iput-object p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->b:Landroid/content/Context;

    .line 46
    invoke-direct {p0, p2}, Lcom/moji/imageview/CertificateRoundImageView;->setCustomAttributes(Landroid/util/AttributeSet;)V

    .line 47
    invoke-direct {p0}, Lcom/moji/imageview/CertificateRoundImageView;->a()V

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .locals 0

    .line 51
    invoke-direct {p0, p1, p2, p3}, Landroid/widget/ImageView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    const/4 p3, 0x0

    .line 23
    iput p3, p0, Lcom/moji/imageview/CertificateRoundImageView;->a:I

    .line 27
    iput p3, p0, Lcom/moji/imageview/CertificateRoundImageView;->d:I

    const/high16 p3, 0x3e800000    # 0.25f

    .line 28
    iput p3, p0, Lcom/moji/imageview/CertificateRoundImageView;->e:F

    .line 52
    iput-object p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->b:Landroid/content/Context;

    .line 53
    invoke-direct {p0, p2}, Lcom/moji/imageview/CertificateRoundImageView;->setCustomAttributes(Landroid/util/AttributeSet;)V

    .line 54
    invoke-direct {p0}, Lcom/moji/imageview/CertificateRoundImageView;->a()V

    return-void
.end method

.method private static a(Landroid/graphics/Bitmap;D)Landroid/graphics/Bitmap;
    .locals 9

    .line 133
    invoke-virtual {p0}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v0

    int-to-float v0, v0

    .line 134
    invoke-virtual {p0}, Landroid/graphics/Bitmap;->getHeight()I

    move-result v1

    int-to-float v1, v1

    .line 136
    new-instance v7, Landroid/graphics/Matrix;

    invoke-direct {v7}, Landroid/graphics/Matrix;-><init>()V

    double-to-float p1, p1

    div-float/2addr p1, v0

    .line 140
    invoke-virtual {v7, p1, p1}, Landroid/graphics/Matrix;->postScale(FF)Z

    float-to-int v5, v0

    float-to-int v6, v1

    const/4 v3, 0x0

    const/4 v4, 0x0

    const/4 v8, 0x1

    move-object v2, p0

    .line 141
    invoke-static/range {v2 .. v8}, Landroid/graphics/Bitmap;->createBitmap(Landroid/graphics/Bitmap;IIIILandroid/graphics/Matrix;Z)Landroid/graphics/Bitmap;

    move-result-object p0

    return-object p0
.end method

.method private a(Landroid/graphics/drawable/Drawable;)Landroid/graphics/Bitmap;
    .locals 1

    .line 114
    instance-of v0, p1, Landroid/graphics/drawable/BitmapDrawable;

    if-eqz v0, :cond_0

    .line 115
    check-cast p1, Landroid/graphics/drawable/BitmapDrawable;

    .line 116
    invoke-virtual {p1}, Landroid/graphics/drawable/BitmapDrawable;->getBitmap()Landroid/graphics/Bitmap;

    move-result-object p1

    return-object p1

    :cond_0
    const/4 p1, 0x0

    return-object p1
.end method

.method private a()V
    .locals 2

    .line 57
    new-instance v0, Landroid/graphics/Matrix;

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

    iput-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->j:Landroid/graphics/Matrix;

    .line 59
    new-instance v0, Landroid/graphics/Paint;

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

    iput-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->g:Landroid/graphics/Paint;

    .line 60
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->g:Landroid/graphics/Paint;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setAntiAlias(Z)V

    .line 61
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->g:Landroid/graphics/Paint;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setFilterBitmap(Z)V

    .line 62
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->g:Landroid/graphics/Paint;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setDither(Z)V

    .line 64
    new-instance v0, Landroid/graphics/Paint;

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

    iput-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->h:Landroid/graphics/Paint;

    .line 65
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->h:Landroid/graphics/Paint;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setAntiAlias(Z)V

    .line 67
    new-instance v0, Landroid/graphics/Path;

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

    iput-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->l:Landroid/graphics/Path;

    return-void
.end method

.method private b(Landroid/graphics/Canvas;)V
    .locals 4

    .line 123
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->f:Landroid/graphics/drawable/BitmapDrawable;

    if-nez v0, :cond_0

    return-void

    .line 126
    :cond_0
    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getWidth()I

    move-result v0

    int-to-float v0, v0

    iget v1, p0, Lcom/moji/imageview/CertificateRoundImageView;->e:F

    mul-float v0, v0, v1

    .line 127
    iget-object v1, p0, Lcom/moji/imageview/CertificateRoundImageView;->f:Landroid/graphics/drawable/BitmapDrawable;

    invoke-virtual {v1}, Landroid/graphics/drawable/BitmapDrawable;->getBitmap()Landroid/graphics/Bitmap;

    move-result-object v1

    float-to-double v2, v0

    invoke-static {v1, v2, v3}, Lcom/moji/imageview/CertificateRoundImageView;->a(Landroid/graphics/Bitmap;D)Landroid/graphics/Bitmap;

    move-result-object v0

    .line 128
    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getWidth()I

    move-result v1

    invoke-virtual {v0}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v2

    sub-int/2addr v1, v2

    int-to-float v1, v1

    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getWidth()I

    move-result v2

    invoke-virtual {v0}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v3

    sub-int/2addr v2, v3

    int-to-float v2, v2

    const/4 v3, 0x0

    invoke-virtual {p1, v0, v1, v2, v3}, Landroid/graphics/Canvas;->drawBitmap(Landroid/graphics/Bitmap;FFLandroid/graphics/Paint;)V

    return-void
.end method

.method private setCertificateDrawableRes(I)V
    .locals 1
    .param p1    # I
        .annotation build Landroid/support/annotation/DrawableRes;
        .end annotation
    .end param

    .line 163
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->b:Landroid/content/Context;

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

    move-result-object v0

    invoke-virtual {v0, p1}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v0

    .line 164
    instance-of v0, v0, Landroid/graphics/drawable/BitmapDrawable;

    if-eqz v0, :cond_0

    .line 165
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->b:Landroid/content/Context;

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

    move-result-object v0

    invoke-virtual {v0, p1}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object p1

    check-cast p1, Landroid/graphics/drawable/BitmapDrawable;

    iput-object p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->f:Landroid/graphics/drawable/BitmapDrawable;

    goto :goto_0

    :cond_0
    const/4 p1, 0x0

    .line 167
    iput-object p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->f:Landroid/graphics/drawable/BitmapDrawable;

    :goto_0
    return-void
.end method

.method private setCustomAttributes(Landroid/util/AttributeSet;)V
    .locals 2

    .line 71
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->b:Landroid/content/Context;

    sget-object v1, Lcom/moji/widget/R$styleable;->roundedimageview:[I

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

    move-result-object p1

    .line 72
    sget v0, Lcom/moji/widget/R$styleable;->roundedimageview_border_thickness:I

    const/4 v1, 0x0

    invoke-virtual {p1, v0, v1}, Landroid/content/res/TypedArray;->getDimensionPixelSize(II)I

    move-result v0

    iput v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->a:I

    .line 73
    sget v0, Lcom/moji/widget/R$styleable;->roundedimageview_border_inside_color:I

    sget v1, Lcom/moji/imageview/CertificateRoundImageView;->c:I

    invoke-virtual {p1, v0, v1}, Landroid/content/res/TypedArray;->getColor(II)I

    move-result v0

    iput v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->d:I

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

    return-void
.end method

.method private setShader(Landroid/graphics/drawable/Drawable;)V
    .locals 3

    .line 97
    invoke-direct {p0, p1}, Lcom/moji/imageview/CertificateRoundImageView;->a(Landroid/graphics/drawable/Drawable;)Landroid/graphics/Bitmap;

    move-result-object p1

    if-nez p1, :cond_0

    return-void

    .line 102
    :cond_0
    new-instance v0, Landroid/graphics/BitmapShader;

    sget-object v1, Landroid/graphics/Shader$TileMode;->CLAMP:Landroid/graphics/Shader$TileMode;

    sget-object v2, Landroid/graphics/Shader$TileMode;->CLAMP:Landroid/graphics/Shader$TileMode;

    invoke-direct {v0, p1, v1, v2}, Landroid/graphics/BitmapShader;-><init>(Landroid/graphics/Bitmap;Landroid/graphics/Shader$TileMode;Landroid/graphics/Shader$TileMode;)V

    iput-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->i:Landroid/graphics/BitmapShader;

    .line 103
    invoke-virtual {p1}, Landroid/graphics/Bitmap;->getWidth()I

    move-result v0

    invoke-virtual {p1}, Landroid/graphics/Bitmap;->getHeight()I

    move-result p1

    invoke-static {v0, p1}, Ljava/lang/Math;->min(II)I

    move-result p1

    .line 104
    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getMeasuredWidth()I

    move-result v0

    iget v1, p0, Lcom/moji/imageview/CertificateRoundImageView;->a:I

    mul-int/lit8 v1, v1, 0x2

    sub-int/2addr v0, v1

    int-to-float v0, v0

    int-to-float p1, p1

    div-float/2addr v0, p1

    .line 106
    iget-object p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->j:Landroid/graphics/Matrix;

    invoke-virtual {p1, v0, v0}, Landroid/graphics/Matrix;->setScale(FF)V

    .line 108
    iget-object p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->i:Landroid/graphics/BitmapShader;

    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->j:Landroid/graphics/Matrix;

    invoke-virtual {p1, v0}, Landroid/graphics/BitmapShader;->setLocalMatrix(Landroid/graphics/Matrix;)V

    .line 110
    iget-object p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->h:Landroid/graphics/Paint;

    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->i:Landroid/graphics/BitmapShader;

    invoke-virtual {p1, v0}, Landroid/graphics/Paint;->setShader(Landroid/graphics/Shader;)Landroid/graphics/Shader;

    return-void
.end method


# virtual methods
.method protected a(Landroid/graphics/Canvas;)V
    .locals 5

    .line 145
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->l:Landroid/graphics/Path;

    invoke-virtual {v0}, Landroid/graphics/Path;->reset()V

    .line 146
    iget v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->a:I

    int-to-float v0, v0

    const/high16 v1, 0x3f000000    # 0.5f

    mul-float v0, v0, v1

    .line 147
    iget-object v1, p0, Lcom/moji/imageview/CertificateRoundImageView;->g:Landroid/graphics/Paint;

    iget v2, p0, Lcom/moji/imageview/CertificateRoundImageView;->a:I

    int-to-float v2, v2

    invoke-virtual {v1, v2}, Landroid/graphics/Paint;->setStrokeWidth(F)V

    .line 148
    iget-object v1, p0, Lcom/moji/imageview/CertificateRoundImageView;->l:Landroid/graphics/Path;

    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getWidth()I

    move-result v2

    div-int/lit8 v2, v2, 0x2

    int-to-float v2, v2

    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getHeight()I

    move-result v3

    div-int/lit8 v3, v3, 0x2

    int-to-float v3, v3

    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getWidth()I

    move-result v4

    div-int/lit8 v4, v4, 0x2

    int-to-float v4, v4

    sub-float/2addr v4, v0

    sget-object v0, Landroid/graphics/Path$Direction;->CW:Landroid/graphics/Path$Direction;

    invoke-virtual {v1, v2, v3, v4, v0}, Landroid/graphics/Path;->addCircle(FFFLandroid/graphics/Path$Direction;)V

    .line 149
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->g:Landroid/graphics/Paint;

    sget-object v1, Landroid/graphics/Paint$Style;->STROKE:Landroid/graphics/Paint$Style;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V

    .line 150
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->g:Landroid/graphics/Paint;

    iget v1, p0, Lcom/moji/imageview/CertificateRoundImageView;->d:I

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setColor(I)V

    .line 151
    iget-object v0, p0, Lcom/moji/imageview/CertificateRoundImageView;->l:Landroid/graphics/Path;

    iget-object v1, p0, Lcom/moji/imageview/CertificateRoundImageView;->g:Landroid/graphics/Paint;

    invoke-virtual {p1, v0, v1}, Landroid/graphics/Canvas;->drawPath(Landroid/graphics/Path;Landroid/graphics/Paint;)V

    return-void
.end method

.method protected onDraw(Landroid/graphics/Canvas;)V
    .locals 4

    .line 85
    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getDrawable()Landroid/graphics/drawable/Drawable;

    move-result-object v0

    .line 86
    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->isInEditMode()Z

    move-result v1

    if-nez v1, :cond_0

    instance-of v1, v0, Landroid/graphics/drawable/BitmapDrawable;

    if-eqz v1, :cond_0

    .line 87
    invoke-virtual {p0, p1}, Lcom/moji/imageview/CertificateRoundImageView;->a(Landroid/graphics/Canvas;)V

    .line 88
    invoke-direct {p0, v0}, Lcom/moji/imageview/CertificateRoundImageView;->setShader(Landroid/graphics/drawable/Drawable;)V

    .line 89
    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getMeasuredWidth()I

    move-result v0

    div-int/lit8 v0, v0, 0x2

    int-to-float v0, v0

    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getMeasuredWidth()I

    move-result v1

    div-int/lit8 v1, v1, 0x2

    int-to-float v1, v1

    iget v2, p0, Lcom/moji/imageview/CertificateRoundImageView;->k:F

    iget-object v3, p0, Lcom/moji/imageview/CertificateRoundImageView;->h:Landroid/graphics/Paint;

    invoke-virtual {p1, v0, v1, v2, v3}, Landroid/graphics/Canvas;->drawCircle(FFFLandroid/graphics/Paint;)V

    .line 90
    invoke-direct {p0, p1}, Lcom/moji/imageview/CertificateRoundImageView;->b(Landroid/graphics/Canvas;)V

    goto :goto_0

    .line 92
    :cond_0
    invoke-super {p0, p1}, Landroid/widget/ImageView;->onDraw(Landroid/graphics/Canvas;)V

    :goto_0
    return-void
.end method

.method protected onMeasure(II)V
    .locals 0

    .line 79
    invoke-super {p0, p1, p2}, Landroid/widget/ImageView;->onMeasure(II)V

    .line 80
    invoke-virtual {p0}, Lcom/moji/imageview/CertificateRoundImageView;->getMeasuredWidth()I

    move-result p1

    iget p2, p0, Lcom/moji/imageview/CertificateRoundImageView;->a:I

    mul-int/lit8 p2, p2, 0x2

    sub-int/2addr p1, p2

    int-to-float p1, p1

    const/high16 p2, 0x40000000    # 2.0f

    div-float/2addr p1, p2

    iput p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->k:F

    return-void
.end method

.method public setBorderOutsideColor(I)V
    .locals 0

    .line 159
    iput p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->d:I

    return-void
.end method

.method public setBorderThickness(I)V
    .locals 0

    .line 155
    iput p1, p0, Lcom/moji/imageview/CertificateRoundImageView;->a:I

    return-void
.end method

.method public setCertificateType(I)V
    .locals 1

    const/4 v0, 0x1

    if-ne p1, v0, :cond_0

    .line 173
    sget p1, Lcom/moji/widget/R$drawable;->icon_persion_certificate:I

    invoke-direct {p0, p1}, Lcom/moji/imageview/CertificateRoundImageView;->setCertificateDrawableRes(I)V

    goto :goto_0

    :cond_0
    const/4 v0, 0x2

    if-ne p1, v0, :cond_1

    .line 175
    sget p1, Lcom/moji/widget/R$drawable;->iocn_offical_certificate:I

    invoke-direct {p0, p1}, Lcom/moji/imageview/CertificateRoundImageView;->setCertificateDrawableRes(I)V

    goto :goto_0

    .line 177
    :cond_1
    sget p1, Lcom/moji/widget/R$drawable;->transparent:I

    invoke-direct {p0, p1}, Lcom/moji/imageview/CertificateRoundImageView;->setCertificateDrawableRes(I)V

    :goto_0
    return-void
.end method
