You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
633 lines
15 KiB
633 lines
15 KiB
.class public final Lcom/viatech/util/VPaiPicasso$MemDiskCache; |
|
.super Ljava/lang/Object; |
|
.source "VPaiPicasso.java" |
|
|
|
# interfaces |
|
.implements Lcom/squareup/picasso/Cache; |
|
|
|
|
|
# annotations |
|
.annotation system Ldalvik/annotation/EnclosingClass; |
|
value = Lcom/viatech/util/VPaiPicasso; |
|
.end annotation |
|
|
|
.annotation system Ldalvik/annotation/InnerClass; |
|
accessFlags = 0x19 |
|
name = "MemDiskCache" |
|
.end annotation |
|
|
|
|
|
# instance fields |
|
.field private mDiskLruCache:Llibcore/io/DiskLruCache; |
|
|
|
.field private mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
|
|
# direct methods |
|
.method public constructor <init>(Landroid/content/Context;)V |
|
.locals 6 |
|
|
|
.prologue |
|
.line 68 |
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V |
|
|
|
.line 69 |
|
new-instance v0, Lcom/squareup/picasso/LruCache; |
|
|
|
invoke-direct {v0, p1}, Lcom/squareup/picasso/LruCache;-><init>(Landroid/content/Context;)V |
|
|
|
iput-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
.line 71 |
|
const-string v0, "vpaithumbcache" |
|
|
|
invoke-static {p1, v0}, Lcom/viatech/util/VPaiPicasso;->access$000(Landroid/content/Context;Ljava/lang/String;)Ljava/io/File; |
|
|
|
move-result-object v0 |
|
|
|
.line 72 |
|
invoke-virtual {v0}, Ljava/io/File;->exists()Z |
|
|
|
move-result v1 |
|
|
|
if-nez v1, :cond_0 |
|
|
|
.line 73 |
|
invoke-virtual {v0}, Ljava/io/File;->mkdirs()Z |
|
|
|
.line 75 |
|
:cond_0 |
|
const-string v1, "VpaiPicasso" |
|
|
|
new-instance v2, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
const-string v3, "dir is " |
|
|
|
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v2 |
|
|
|
invoke-virtual {v0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String; |
|
|
|
move-result-object v3 |
|
|
|
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v2 |
|
|
|
const-string v3, ", max size is " |
|
|
|
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v2 |
|
|
|
iget-object v3, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
invoke-virtual {v3}, Lcom/squareup/picasso/LruCache;->maxSize()I |
|
|
|
move-result v3 |
|
|
|
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v2 |
|
|
|
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v2 |
|
|
|
invoke-static {v1, v2}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
.line 78 |
|
const/16 v1, 0xb |
|
|
|
const/4 v2, 0x1 |
|
|
|
const-wide/32 v4, 0xa00000 |
|
|
|
:try_start_0 |
|
invoke-static {v0, v1, v2, v4, v5}, Llibcore/io/DiskLruCache;->open(Ljava/io/File;IIJ)Llibcore/io/DiskLruCache; |
|
|
|
move-result-object v0 |
|
|
|
iput-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mDiskLruCache:Llibcore/io/DiskLruCache; |
|
:try_end_0 |
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0 |
|
|
|
.line 82 |
|
:goto_0 |
|
return-void |
|
|
|
.line 79 |
|
:catch_0 |
|
move-exception v0 |
|
|
|
.line 80 |
|
invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V |
|
|
|
goto :goto_0 |
|
.end method |
|
|
|
.method private bytesToHexString([B)Ljava/lang/String; |
|
.locals 5 |
|
|
|
.prologue |
|
.line 198 |
|
new-instance v1, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
.line 199 |
|
const/4 v0, 0x0 |
|
|
|
:goto_0 |
|
array-length v2, p1 |
|
|
|
if-ge v0, v2, :cond_1 |
|
|
|
.line 200 |
|
aget-byte v2, p1, v0 |
|
|
|
and-int/lit16 v2, v2, 0xff |
|
|
|
invoke-static {v2}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String; |
|
|
|
move-result-object v2 |
|
|
|
.line 201 |
|
invoke-virtual {v2}, Ljava/lang/String;->length()I |
|
|
|
move-result v3 |
|
|
|
const/4 v4, 0x1 |
|
|
|
if-ne v3, v4, :cond_0 |
|
|
|
.line 202 |
|
const/16 v3, 0x30 |
|
|
|
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder; |
|
|
|
.line 204 |
|
:cond_0 |
|
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
.line 199 |
|
add-int/lit8 v0, v0, 0x1 |
|
|
|
goto :goto_0 |
|
|
|
.line 206 |
|
:cond_1 |
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
return-object v0 |
|
.end method |
|
|
|
|
|
# virtual methods |
|
.method public clear()V |
|
.locals 1 |
|
|
|
.prologue |
|
.line 171 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
invoke-virtual {v0}, Lcom/squareup/picasso/LruCache;->clear()V |
|
|
|
.line 173 |
|
return-void |
|
.end method |
|
|
|
.method public clearKeyUri(Ljava/lang/String;)V |
|
.locals 1 |
|
|
|
.prologue |
|
.line 177 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
invoke-virtual {v0, p1}, Lcom/squareup/picasso/LruCache;->clearKeyUri(Ljava/lang/String;)V |
|
|
|
.line 179 |
|
return-void |
|
.end method |
|
|
|
.method public get(Ljava/lang/String;)Landroid/graphics/Bitmap; |
|
.locals 5 |
|
|
|
.prologue |
|
const/4 v1, 0x0 |
|
|
|
.line 86 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
invoke-virtual {v0, p1}, Lcom/squareup/picasso/LruCache;->get(Ljava/lang/String;)Landroid/graphics/Bitmap; |
|
|
|
move-result-object v0 |
|
|
|
.line 87 |
|
if-eqz v0, :cond_0 |
|
|
|
invoke-virtual {v0}, Landroid/graphics/Bitmap;->isRecycled()Z |
|
|
|
move-result v2 |
|
|
|
if-nez v2, :cond_0 |
|
|
|
.line 123 |
|
:goto_0 |
|
return-object v0 |
|
|
|
.line 91 |
|
:cond_0 |
|
:try_start_0 |
|
invoke-virtual {p0, p1}, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->hashKeyForDisk(Ljava/lang/String;)Ljava/lang/String; |
|
|
|
move-result-object v2 |
|
|
|
.line 93 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mDiskLruCache:Llibcore/io/DiskLruCache; |
|
|
|
invoke-virtual {v0, v2}, Llibcore/io/DiskLruCache;->get(Ljava/lang/String;)Llibcore/io/DiskLruCache$Snapshot; |
|
|
|
move-result-object v0 |
|
|
|
.line 94 |
|
if-nez v0, :cond_1 |
|
|
|
move-object v0, v1 |
|
|
|
.line 95 |
|
goto :goto_0 |
|
|
|
.line 98 |
|
:cond_1 |
|
const/4 v3, 0x0 |
|
|
|
invoke-virtual {v0, v3}, Llibcore/io/DiskLruCache$Snapshot;->getInputStream(I)Ljava/io/InputStream; |
|
|
|
move-result-object v0 |
|
|
|
check-cast v0, Ljava/io/FileInputStream; |
|
|
|
.line 99 |
|
invoke-virtual {v0}, Ljava/io/FileInputStream;->getFD()Ljava/io/FileDescriptor; |
|
|
|
move-result-object v0 |
|
|
|
.line 100 |
|
if-nez v0, :cond_2 |
|
|
|
.line 101 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mDiskLruCache:Llibcore/io/DiskLruCache; |
|
|
|
invoke-virtual {v0, v2}, Llibcore/io/DiskLruCache;->remove(Ljava/lang/String;)Z |
|
|
|
.line 102 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mDiskLruCache:Llibcore/io/DiskLruCache; |
|
|
|
invoke-virtual {v0}, Llibcore/io/DiskLruCache;->flush()V |
|
|
|
move-object v0, v1 |
|
|
|
.line 103 |
|
goto :goto_0 |
|
|
|
.line 107 |
|
:cond_2 |
|
invoke-static {v0}, Landroid/graphics/BitmapFactory;->decodeFileDescriptor(Ljava/io/FileDescriptor;)Landroid/graphics/Bitmap; |
|
|
|
move-result-object v0 |
|
|
|
.line 108 |
|
if-nez v0, :cond_3 |
|
|
|
.line 109 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mDiskLruCache:Llibcore/io/DiskLruCache; |
|
|
|
invoke-virtual {v0, v2}, Llibcore/io/DiskLruCache;->remove(Ljava/lang/String;)Z |
|
|
|
.line 110 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mDiskLruCache:Llibcore/io/DiskLruCache; |
|
|
|
invoke-virtual {v0}, Llibcore/io/DiskLruCache;->flush()V |
|
|
|
move-object v0, v1 |
|
|
|
.line 111 |
|
goto :goto_0 |
|
|
|
.line 114 |
|
:cond_3 |
|
const-string v2, "VpaiPicasso" |
|
|
|
new-instance v3, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
const-string v4, "set new bitmap " |
|
|
|
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v3 |
|
|
|
invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v3 |
|
|
|
const-string v4, " of url " |
|
|
|
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v3 |
|
|
|
invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v3 |
|
|
|
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v3 |
|
|
|
invoke-static {v2, v3}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
.line 115 |
|
iget-object v2, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
invoke-virtual {v2, p1, v0}, Lcom/squareup/picasso/LruCache;->set(Ljava/lang/String;Landroid/graphics/Bitmap;)V |
|
:try_end_0 |
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0 |
|
.catch Ljava/lang/OutOfMemoryError; {:try_start_0 .. :try_end_0} :catch_1 |
|
|
|
goto :goto_0 |
|
|
|
.line 118 |
|
:catch_0 |
|
move-exception v0 |
|
|
|
.line 119 |
|
const-string v2, "VpaiPicasso" |
|
|
|
new-instance v3, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
const-string v4, "Error: get() " |
|
|
|
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v3 |
|
|
|
invoke-virtual {v0}, Ljava/io/IOException;->getMessage()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
invoke-static {v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
:goto_1 |
|
move-object v0, v1 |
|
|
|
.line 123 |
|
goto :goto_0 |
|
|
|
.line 120 |
|
:catch_1 |
|
move-exception v0 |
|
|
|
.line 121 |
|
const-string v2, "VpaiPicasso" |
|
|
|
new-instance v3, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
const-string v4, "Error: get() " |
|
|
|
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v3 |
|
|
|
invoke-virtual {v0}, Ljava/lang/OutOfMemoryError;->getMessage()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
invoke-static {v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
goto :goto_1 |
|
.end method |
|
|
|
.method public hashKeyForDisk(Ljava/lang/String;)Ljava/lang/String; |
|
.locals 2 |
|
|
|
.prologue |
|
.line 187 |
|
:try_start_0 |
|
const-string v0, "MD5" |
|
|
|
invoke-static {v0}, Ljava/security/MessageDigest;->getInstance(Ljava/lang/String;)Ljava/security/MessageDigest; |
|
|
|
move-result-object v0 |
|
|
|
.line 188 |
|
invoke-virtual {p1}, Ljava/lang/String;->getBytes()[B |
|
|
|
move-result-object v1 |
|
|
|
invoke-virtual {v0, v1}, Ljava/security/MessageDigest;->update([B)V |
|
|
|
.line 190 |
|
invoke-virtual {v0}, Ljava/security/MessageDigest;->digest()[B |
|
|
|
move-result-object v0 |
|
|
|
invoke-direct {p0, v0}, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->bytesToHexString([B)Ljava/lang/String; |
|
:try_end_0 |
|
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_0 |
|
|
|
move-result-object v0 |
|
|
|
.line 194 |
|
:goto_0 |
|
return-object v0 |
|
|
|
.line 191 |
|
:catch_0 |
|
move-exception v0 |
|
|
|
.line 192 |
|
invoke-virtual {p1}, Ljava/lang/String;->hashCode()I |
|
|
|
move-result v0 |
|
|
|
invoke-static {v0}, Ljava/lang/String;->valueOf(I)Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
goto :goto_0 |
|
.end method |
|
|
|
.method public maxSize()I |
|
.locals 1 |
|
|
|
.prologue |
|
.line 166 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
invoke-virtual {v0}, Lcom/squareup/picasso/LruCache;->maxSize()I |
|
|
|
move-result v0 |
|
|
|
return v0 |
|
.end method |
|
|
|
.method public set(Ljava/lang/String;Landroid/graphics/Bitmap;)V |
|
.locals 4 |
|
|
|
.prologue |
|
.line 128 |
|
if-eqz p1, :cond_0 |
|
|
|
if-nez p2, :cond_1 |
|
|
|
.line 157 |
|
:cond_0 |
|
:goto_0 |
|
return-void |
|
|
|
.line 132 |
|
:cond_1 |
|
:try_start_0 |
|
invoke-virtual {p2}, Landroid/graphics/Bitmap;->isRecycled()Z |
|
|
|
move-result v0 |
|
|
|
if-nez v0, :cond_0 |
|
|
|
.line 136 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
invoke-virtual {v0, p1, p2}, Lcom/squareup/picasso/LruCache;->set(Ljava/lang/String;Landroid/graphics/Bitmap;)V |
|
|
|
.line 140 |
|
invoke-virtual {p0, p1}, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->hashKeyForDisk(Ljava/lang/String;)Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
.line 142 |
|
iget-object v1, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mDiskLruCache:Llibcore/io/DiskLruCache; |
|
|
|
invoke-virtual {v1, v0}, Llibcore/io/DiskLruCache;->edit(Ljava/lang/String;)Llibcore/io/DiskLruCache$Editor; |
|
|
|
move-result-object v0 |
|
|
|
.line 143 |
|
if-eqz v0, :cond_2 |
|
|
|
.line 144 |
|
const/4 v1, 0x0 |
|
|
|
invoke-virtual {v0, v1}, Llibcore/io/DiskLruCache$Editor;->newOutputStream(I)Ljava/io/OutputStream; |
|
|
|
move-result-object v1 |
|
|
|
.line 146 |
|
sget-object v2, Landroid/graphics/Bitmap$CompressFormat;->JPEG:Landroid/graphics/Bitmap$CompressFormat; |
|
|
|
const/16 v3, 0x50 |
|
|
|
invoke-virtual {p2, v2, v3, v1}, Landroid/graphics/Bitmap;->compress(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z |
|
|
|
move-result v1 |
|
|
|
.line 147 |
|
if-eqz v1, :cond_3 |
|
|
|
.line 148 |
|
invoke-virtual {v0}, Llibcore/io/DiskLruCache$Editor;->commit()V |
|
|
|
.line 153 |
|
:cond_2 |
|
:goto_1 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mDiskLruCache:Llibcore/io/DiskLruCache; |
|
|
|
invoke-virtual {v0}, Llibcore/io/DiskLruCache;->flush()V |
|
:try_end_0 |
|
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0 |
|
|
|
goto :goto_0 |
|
|
|
.line 154 |
|
:catch_0 |
|
move-exception v0 |
|
|
|
.line 155 |
|
const-string v1, "VpaiPicasso" |
|
|
|
new-instance v2, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
const-string v3, "Error: set() " |
|
|
|
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v2 |
|
|
|
invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
invoke-static {v1, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
goto :goto_0 |
|
|
|
.line 150 |
|
:cond_3 |
|
:try_start_1 |
|
invoke-virtual {v0}, Llibcore/io/DiskLruCache$Editor;->abort()V |
|
:try_end_1 |
|
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0 |
|
|
|
goto :goto_1 |
|
.end method |
|
|
|
.method public size()I |
|
.locals 1 |
|
|
|
.prologue |
|
.line 161 |
|
iget-object v0, p0, Lcom/viatech/util/VPaiPicasso$MemDiskCache;->mMemoryCache:Lcom/squareup/picasso/LruCache; |
|
|
|
invoke-virtual {v0}, Lcom/squareup/picasso/LruCache;->size()I |
|
|
|
move-result v0 |
|
|
|
return v0 |
|
.end method
|
|
|