FixedAspectRatioRelativeLayout.smali

.class public Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;
.super Landroid/widget/RelativeLayout;
.source "FixedAspectRatioRelativeLayout.java"


# static fields
.field private static final DEFAULT_HEIGHT:I = 0x9

.field private static final DEFAULT_WIDTH:I = 0x10


# instance fields
.field private aspectRatioHeight:I

.field private aspectRatioWidth:I

.field private isRatioChanged:Z


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

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

    const/4 v0, 0x0

    .line 16
    iput-boolean v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->isRatioChanged:Z

    const/4 v0, 0x0

    .line 20
    invoke-direct {p0, p1, v0}, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->init(Landroid/content/Context;Landroid/util/AttributeSet;)V

    return-void
.end method

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

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

    const/4 v0, 0x0

    .line 16
    iput-boolean v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->isRatioChanged:Z

    .line 25
    invoke-direct {p0, p1, p2}, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->init(Landroid/content/Context;Landroid/util/AttributeSet;)V

    return-void
.end method

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

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

    const/4 p3, 0x0

    .line 16
    iput-boolean p3, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->isRatioChanged:Z

    .line 30
    invoke-direct {p0, p1, p2}, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->init(Landroid/content/Context;Landroid/util/AttributeSet;)V

    return-void
.end method

.method private init(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .registers 4

    .line 34
    sget-object v0, Lhurriyet/mobil/android/hurriyet/R$styleable;->FixedAspectRatioRelativeLayout:[I

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

    move-result-object p1

    const/4 p2, 0x0

    const/16 v0, 0x10

    .line 35
    invoke-virtual {p1, p2, v0}, Landroid/content/res/TypedArray;->getInt(II)I

    move-result p2

    iput p2, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    const/4 p2, 0x1

    const/16 v0, 0x9

    .line 36
    invoke-virtual {p1, p2, v0}, Landroid/content/res/TypedArray;->getInt(II)I

    move-result p2

    iput p2, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    .line 37
    invoke-direct {p0}, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->normalizeWidthHeight()V

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

    return-void
.end method

.method private normalizeWidthHeight()V
    .registers 5

    .line 51
    iget v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    const/16 v1, 0x9

    const/16 v2, 0x10

    const/4 v3, 0x1

    if-ge v0, v3, :cond_d

    .line 52
    iput v2, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    .line 53
    iput v1, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    .line 56
    :cond_d
    iget v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    if-ge v0, v3, :cond_15

    .line 57
    iput v2, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    .line 58
    iput v1, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    :cond_15
    return-void
.end method


# virtual methods
.method public getAspectRatioHeight()I
    .registers 2

    .line 97
    iget v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    return v0
.end method

.method public getAspectRatioWidth()I
    .registers 2

    .line 93
    iget v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    return v0
.end method

.method public isAspectRatio4_3()Z
    .registers 3

    .line 84
    iget v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    if-eqz v0, :cond_d

    iget v1, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    if-nez v1, :cond_9

    goto :goto_d

    :cond_9
    int-to-float v0, v0

    int-to-float v1, v1

    div-float/2addr v0, v1

    goto :goto_10

    :cond_d
    :goto_d
    const v0, 0x3fe38e39

    :goto_10
    const v1, 0x3fa66666    # 1.3f

    cmpl-float v1, v0, v1

    if-lez v1, :cond_20

    const v1, 0x3faccccd    # 1.35f

    cmpg-float v0, v0, v1

    if-gez v0, :cond_20

    const/4 v0, 0x1

    goto :goto_21

    :cond_20
    const/4 v0, 0x0

    :goto_21
    return v0
.end method

.method public isRatioChanged()Z
    .registers 2

    .line 75
    iget-boolean v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->isRatioChanged:Z

    return v0
.end method

.method public isRatioEqual(II)Z
    .registers 5

    .line 79
    iget v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    int-to-float v0, v0

    iget v1, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    int-to-float v1, v1

    div-float/2addr v0, v1

    int-to-float p1, p1

    int-to-float p2, p2

    div-float/2addr p1, p2

    cmpl-float p1, v0, p1

    if-nez p1, :cond_10

    const/4 p1, 0x1

    goto :goto_11

    :cond_10
    const/4 p1, 0x0

    :goto_11
    return p1
.end method

.method protected onMeasure(II)V
    .registers 4

    .line 43
    invoke-static {p1}, Landroid/view/View$MeasureSpec;->getSize(I)I

    move-result p1

    .line 44
    invoke-direct {p0}, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->normalizeWidthHeight()V

    .line 45
    iget p2, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    mul-int p2, p2, p1

    iget v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    div-int/2addr p2, v0

    const/high16 v0, 0x40000000    # 2.0f

    .line 46
    invoke-static {p1, v0}, Landroid/view/View$MeasureSpec;->makeMeasureSpec(II)I

    move-result p1

    invoke-static {p2, v0}, Landroid/view/View$MeasureSpec;->makeMeasureSpec(II)I

    move-result p2

    invoke-super {p0, p1, p2}, Landroid/widget/RelativeLayout;->onMeasure(II)V

    return-void
.end method

.method public setRatioForNewValues(II)V
    .registers 6

    const/4 v0, 0x0

    if-eqz p1, :cond_1f

    if-nez p2, :cond_6

    goto :goto_1f

    .line 68
    :cond_6
    iput p1, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    .line 69
    iput p2, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    .line 70
    invoke-direct {p0}, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->normalizeWidthHeight()V

    .line 71
    iget v1, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioWidth:I

    int-to-float v1, v1

    iget v2, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->aspectRatioHeight:I

    int-to-float v2, v2

    div-float/2addr v1, v2

    int-to-float p1, p1

    int-to-float p2, p2

    div-float/2addr p1, p2

    cmpl-float p1, v1, p1

    if-eqz p1, :cond_1c

    const/4 v0, 0x1

    :cond_1c
    iput-boolean v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->isRatioChanged:Z

    return-void

    .line 65
    :cond_1f
    :goto_1f
    iput-boolean v0, p0, Lhurriyet/mobil/android/hurriyet/views/FixedAspectRatioRelativeLayout;->isRatioChanged:Z

    return-void
.end method