ImageCache$ImageCacheParams.smali

.class public Lcom/hurizem/untils/ImageCache$ImageCacheParams;
.super Ljava/lang/Object;
.source "ImageCache.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/hurizem/untils/ImageCache;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x9
    name = "ImageCacheParams"
.end annotation


# instance fields
.field public clearDiskCacheOnStart:Z

.field public compressFormat:Landroid/graphics/Bitmap$CompressFormat;

.field public compressQuality:I

.field public diskCacheDir:Ljava/io/File;

.field public diskCacheEnabled:Z

.field public diskCacheSize:I

.field public initDiskCacheOnCreate:Z

.field private mContext:Landroid/content/Context;

.field public memCacheSize:I

.field public memoryCacheEnabled:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;Ljava/lang/String;)V
    .registers 4
    .annotation system Ldalvik/annotation/MethodParameters;
        accessFlags = {
            0x0,
            0x0
        }
        names = {
            "context",
            "uniqueName"
        }
    .end annotation

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

    const/high16 v0, 0x500000

    .line 84
    iput v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->memCacheSize:I

    const/high16 v0, 0xa00000

    .line 85
    iput v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->diskCacheSize:I

    .line 87
    # getter for: Lcom/hurizem/untils/ImageCache;->DEFAULT_COMPRESS_FORMAT:Landroid/graphics/Bitmap$CompressFormat;
    invoke-static {}, Lcom/hurizem/untils/ImageCache;->access$000()Landroid/graphics/Bitmap$CompressFormat;

    move-result-object v0

    iput-object v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->compressFormat:Landroid/graphics/Bitmap$CompressFormat;

    const/16 v0, 0x46

    .line 88
    iput v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->compressQuality:I

    const/4 v0, 0x1

    .line 89
    iput-boolean v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->memoryCacheEnabled:Z

    .line 90
    iput-boolean v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->diskCacheEnabled:Z

    const/4 v0, 0x0

    .line 91
    iput-boolean v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->clearDiskCacheOnStart:Z

    .line 92
    iput-boolean v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->initDiskCacheOnCreate:Z

    .line 96
    iput-object p1, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->mContext:Landroid/content/Context;

    .line 97
    invoke-static {p1, p2}, Lcom/hurizem/untils/ImageCache;->getDiskCacheDir(Landroid/content/Context;Ljava/lang/String;)Ljava/io/File;

    move-result-object p1

    iput-object p1, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->diskCacheDir:Ljava/io/File;

    return-void
.end method

.method public constructor <init>(Ljava/io/File;)V
    .registers 3
    .annotation system Ldalvik/annotation/MethodParameters;
        accessFlags = {
            0x0
        }
        names = {
            "diskCacheDir"
        }
    .end annotation

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

    const/high16 v0, 0x500000

    .line 84
    iput v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->memCacheSize:I

    const/high16 v0, 0xa00000

    .line 85
    iput v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->diskCacheSize:I

    .line 87
    # getter for: Lcom/hurizem/untils/ImageCache;->DEFAULT_COMPRESS_FORMAT:Landroid/graphics/Bitmap$CompressFormat;
    invoke-static {}, Lcom/hurizem/untils/ImageCache;->access$000()Landroid/graphics/Bitmap$CompressFormat;

    move-result-object v0

    iput-object v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->compressFormat:Landroid/graphics/Bitmap$CompressFormat;

    const/16 v0, 0x46

    .line 88
    iput v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->compressQuality:I

    const/4 v0, 0x1

    .line 89
    iput-boolean v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->memoryCacheEnabled:Z

    .line 90
    iput-boolean v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->diskCacheEnabled:Z

    const/4 v0, 0x0

    .line 91
    iput-boolean v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->clearDiskCacheOnStart:Z

    .line 92
    iput-boolean v0, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->initDiskCacheOnCreate:Z

    .line 101
    iput-object p1, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->diskCacheDir:Ljava/io/File;

    return-void
.end method

.method private static getMemoryClass(Landroid/content/Context;)I
    .registers 2
    .annotation system Ldalvik/annotation/MethodParameters;
        accessFlags = {
            0x0
        }
        names = {
            "context"
        }
    .end annotation

    const-string v0, "activity"

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

    move-result-object p0

    check-cast p0, Landroid/app/ActivityManager;

    .line 137
    invoke-virtual {p0}, Landroid/app/ActivityManager;->getMemoryClass()I

    move-result p0

    return p0
.end method


# virtual methods
.method public setMemCacheSizePercent(Landroid/content/Context;F)V
    .registers 4
    .annotation system Ldalvik/annotation/MethodParameters;
        accessFlags = {
            0x0,
            0x0
        }
        names = {
            "context",
            "percent"
        }
    .end annotation

    const v0, 0x3d4ccccd    # 0.05f

    cmpg-float v0, p2, v0

    if-ltz v0, :cond_22

    const v0, 0x3f4ccccd    # 0.8f

    cmpl-float v0, p2, v0

    if-gtz v0, :cond_22

    .line 124
    invoke-static {p1}, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->getMemoryClass(Landroid/content/Context;)I

    move-result p1

    int-to-float p1, p1

    mul-float p2, p2, p1

    const/high16 p1, 0x44800000    # 1024.0f

    mul-float p2, p2, p1

    mul-float p2, p2, p1

    invoke-static {p2}, Ljava/lang/Math;->round(F)I

    move-result p1

    iput p1, p0, Lcom/hurizem/untils/ImageCache$ImageCacheParams;->memCacheSize:I

    return-void

    .line 119
    :cond_22
    new-instance p1, Ljava/lang/IllegalArgumentException;

    const-string p2, "setMemCacheSizePercent - percent must be between 0.05 and 0.8 (inclusive)"

    invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p1
.end method