今奥全景相机
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.

834 lines
20 KiB

.class public Lcom/viatech/common/ThumbnailCacheManager;
.super Ljava/lang/Object;
.source "ThumbnailCacheManager.java"
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/viatech/common/ThumbnailCacheManager$BitmapDecodeReq;,
Lcom/viatech/common/ThumbnailCacheManager$ThumbnailCacheListener;
}
.end annotation
# static fields
.field private static CACHE_DIR:Ljava/io/File; = null
.field private static final CACHE_MANAGER_VERSION:I = 0x1c
.field private static final TAG:Ljava/lang/String; = "Vpai_ThumbnailCacheManager"
.field public static final TYPE_LOCAL_THUMB:I = 0x3
.field public static final TYPE_NET_ORIGINAL:I = 0x1
.field public static final TYPE_NET_THUMB:I = 0x2
.field private static mHandler:Landroid/os/Handler;
.field private static sContext:Landroid/content/Context;
.field private static volatile sIns:Lcom/viatech/common/ThumbnailCacheManager;
# instance fields
.field private mDiskLruCache:Llibcore/io/DiskLruCache;
.field private mMemoryCache:Landroid/util/LruCache;
.annotation system Ldalvik/annotation/Signature;
value = {
"Landroid/util/LruCache",
"<",
"Ljava/lang/String;",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
.end field
.field private mThumbnailCacheListenerList:Ljava/util/List;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/List",
"<",
"Lcom/viatech/common/ThumbnailCacheManager$ThumbnailCacheListener;",
">;"
}
.end annotation
.end field
.field private mWorkThread:Lcom/viatech/common/util/WorkThread;
# direct methods
.method static constructor <clinit>()V
.locals 1
.prologue
const/4 v0, 0x0
.line 70
sput-object v0, Lcom/viatech/common/ThumbnailCacheManager;->sIns:Lcom/viatech/common/ThumbnailCacheManager;
.line 71
sput-object v0, Lcom/viatech/common/ThumbnailCacheManager;->CACHE_DIR:Ljava/io/File;
return-void
.end method
.method private constructor <init>(II)V
.locals 6
.prologue
const/4 v3, 0x1
.line 90
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 91
const-string v0, "Vpai_ThumbnailCacheManager"
const-string v1, "=======ThumbnailCacheManager======="
invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
.line 92
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mThumbnailCacheListenerList:Ljava/util/List;
.line 93
new-instance v0, Lcom/viatech/common/ThumbnailCacheManager$1;
invoke-direct {v0, p0, p1}, Lcom/viatech/common/ThumbnailCacheManager$1;-><init>(Lcom/viatech/common/ThumbnailCacheManager;I)V
iput-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mMemoryCache:Landroid/util/LruCache;
.line 108
sget-object v0, Lcom/viatech/common/ThumbnailCacheManager;->sContext:Landroid/content/Context;
const-string v1, "thumb"
invoke-static {v0, v1}, Lcom/viatech/common/ThumbnailCacheManager;->getDiskCacheDir(Landroid/content/Context;Ljava/lang/String;)Ljava/io/File;
move-result-object v0
sput-object v0, Lcom/viatech/common/ThumbnailCacheManager;->CACHE_DIR:Ljava/io/File;
.line 111
:try_start_0
sget-object v0, Lcom/viatech/common/ThumbnailCacheManager;->CACHE_DIR:Ljava/io/File;
.line 112
invoke-virtual {v0}, Ljava/io/File;->exists()Z
move-result v1
if-nez v1, :cond_0
.line 113
invoke-virtual {v0}, Ljava/io/File;->mkdirs()Z
.line 116
:cond_0
const/16 v1, 0x1c
const/4 v2, 0x1
int-to-long v4, p2
.line 117
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/common/ThumbnailCacheManager;->mDiskLruCache:Llibcore/io/DiskLruCache;
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
.line 122
:goto_0
new-instance v0, Lcom/viatech/common/util/WorkThread;
const-string v1, "thumbnail decode"
invoke-direct {v0, v1}, Lcom/viatech/common/util/WorkThread;-><init>(Ljava/lang/String;)V
iput-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mWorkThread:Lcom/viatech/common/util/WorkThread;
.line 123
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mWorkThread:Lcom/viatech/common/util/WorkThread;
invoke-virtual {v0, v3}, Lcom/viatech/common/util/WorkThread;->setDispatchMode(I)V
.line 124
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mWorkThread:Lcom/viatech/common/util/WorkThread;
invoke-virtual {v0}, Lcom/viatech/common/util/WorkThread;->start()V
.line 125
return-void
.line 118
:catch_0
move-exception v0
.line 119
invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
goto :goto_0
.end method
.method static synthetic access$000(Lcom/viatech/common/ThumbnailCacheManager;)Ljava/util/List;
.locals 1
.prologue
.line 54
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mThumbnailCacheListenerList:Ljava/util/List;
return-object v0
.end method
.method static synthetic access$400()Landroid/os/Handler;
.locals 1
.prologue
.line 54
sget-object v0, Lcom/viatech/common/ThumbnailCacheManager;->mHandler:Landroid/os/Handler;
return-object v0
.end method
.method static synthetic access$500(Lcom/viatech/common/ThumbnailCacheManager;)Llibcore/io/DiskLruCache;
.locals 1
.prologue
.line 54
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mDiskLruCache:Llibcore/io/DiskLruCache;
return-object v0
.end method
.method static synthetic access$600(Lcom/viatech/common/ThumbnailCacheManager;)Landroid/util/LruCache;
.locals 1
.prologue
.line 54
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mMemoryCache:Landroid/util/LruCache;
return-object v0
.end method
.method private bytesToHexString([B)Ljava/lang/String;
.locals 5
.prologue
.line 275
new-instance v1, Ljava/lang/StringBuilder;
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
.line 276
const/4 v0, 0x0
:goto_0
array-length v2, p1
if-ge v0, v2, :cond_1
.line 277
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 278
invoke-virtual {v2}, Ljava/lang/String;->length()I
move-result v3
const/4 v4, 0x1
if-ne v3, v4, :cond_0
.line 279
const/16 v3, 0x30
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
.line 281
:cond_0
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 276
add-int/lit8 v0, v0, 0x1
goto :goto_0
.line 283
:cond_1
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
return-object v0
.end method
.method private destory()V
.locals 4
.prologue
.line 221
const-string v0, "Vpai_ThumbnailCacheManager"
const-string v1, "=======destory======="
invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
.line 222
const-class v1, Lcom/viatech/common/ThumbnailCacheManager;
monitor-enter v1
.line 224
:try_start_0
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mDiskLruCache:Llibcore/io/DiskLruCache;
invoke-virtual {v0}, Llibcore/io/DiskLruCache;->close()V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 228
:goto_0
:try_start_1
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mMemoryCache:Landroid/util/LruCache;
invoke-virtual {v0}, Landroid/util/LruCache;->snapshot()Ljava/util/Map;
move-result-object v2
.line 229
invoke-interface {v2}, Ljava/util/Map;->keySet()Ljava/util/Set;
move-result-object v0
.line 230
invoke-interface {v0}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
move-result-object v3
.line 231
:cond_0
:goto_1
invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z
move-result v0
if-eqz v0, :cond_1
.line 232
invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/lang/String;
.line 233
invoke-interface {v2, v0}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/graphics/Bitmap;
.line 234
if-eqz v0, :cond_0
.line 235
invoke-virtual {v0}, Landroid/graphics/Bitmap;->recycle()V
goto :goto_1
.line 242
:catchall_0
move-exception v0
monitor-exit v1
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
throw v0
.line 225
:catch_0
move-exception v0
.line 226
:try_start_2
invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
goto :goto_0
.line 239
:cond_1
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mWorkThread:Lcom/viatech/common/util/WorkThread;
invoke-virtual {v0}, Lcom/viatech/common/util/WorkThread;->exit()V
.line 241
const/4 v0, 0x0
sput-object v0, Lcom/viatech/common/ThumbnailCacheManager;->sIns:Lcom/viatech/common/ThumbnailCacheManager;
.line 242
monitor-exit v1
:try_end_2
.catchall {:try_start_2 .. :try_end_2} :catchall_0
.line 243
return-void
.end method
.method private getAppVersion(Landroid/content/Context;)I
.locals 3
.prologue
.line 250
:try_start_0
invoke-virtual {p1}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;
move-result-object v0
invoke-virtual {p1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
move-result-object v1
const/4 v2, 0x0
invoke-virtual {v0, v1, v2}, Landroid/content/pm/PackageManager;->getPackageInfo(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;
move-result-object v0
.line 252
iget v0, v0, Landroid/content/pm/PackageInfo;->versionCode:I
:try_end_0
.catch Landroid/content/pm/PackageManager$NameNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
.line 256
:goto_0
return v0
.line 253
:catch_0
move-exception v0
.line 254
invoke-virtual {v0}, Landroid/content/pm/PackageManager$NameNotFoundException;->printStackTrace()V
.line 256
const/4 v0, 0x1
goto :goto_0
.end method
.method private static getDiskCacheDir(Landroid/content/Context;Ljava/lang/String;)Ljava/io/File;
.locals 3
.prologue
.line 142
const-string v0, "mounted"
invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v0
if-nez v0, :cond_0
.line 143
invoke-static {}, Landroid/os/Environment;->isExternalStorageRemovable()Z
move-result v0
if-nez v0, :cond_1
:cond_0
invoke-virtual {p0}, Landroid/content/Context;->getExternalCacheDir()Ljava/io/File;
move-result-object v0
if-eqz v0, :cond_1
.line 144
invoke-virtual {p0}, Landroid/content/Context;->getExternalCacheDir()Ljava/io/File;
move-result-object v0
invoke-virtual {v0}, Ljava/io/File;->getPath()Ljava/lang/String;
move-result-object v0
.line 148
:goto_0
new-instance v1, Ljava/io/File;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
sget-object v2, Ljava/io/File;->separator:Ljava/lang/String;
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
invoke-virtual {v0, p1}, 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-direct {v1, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V
return-object v1
.line 146
:cond_1
invoke-virtual {p0}, Landroid/content/Context;->getCacheDir()Ljava/io/File;
move-result-object v0
invoke-virtual {v0}, Ljava/io/File;->getPath()Ljava/lang/String;
move-result-object v0
goto :goto_0
.end method
.method public static initialize(Landroid/content/Context;)V
.locals 1
.prologue
.line 133
sput-object p0, Lcom/viatech/common/ThumbnailCacheManager;->sContext:Landroid/content/Context;
.line 134
new-instance v0, Landroid/os/Handler;
invoke-direct {v0}, Landroid/os/Handler;-><init>()V
sput-object v0, Lcom/viatech/common/ThumbnailCacheManager;->mHandler:Landroid/os/Handler;
.line 135
return-void
.end method
.method public static instance()Lcom/viatech/common/ThumbnailCacheManager;
.locals 5
.prologue
.line 152
sget-object v0, Lcom/viatech/common/ThumbnailCacheManager;->sIns:Lcom/viatech/common/ThumbnailCacheManager;
if-nez v0, :cond_1
.line 153
const-class v1, Lcom/viatech/common/ThumbnailCacheManager;
monitor-enter v1
.line 154
:try_start_0
sget-object v0, Lcom/viatech/common/ThumbnailCacheManager;->sIns:Lcom/viatech/common/ThumbnailCacheManager;
if-nez v0, :cond_0
.line 155
invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/Runtime;->maxMemory()J
move-result-wide v2
long-to-int v0, v2
.line 156
const-string v2, "Vpai_ThumbnailCacheManager"
new-instance v3, Ljava/lang/StringBuilder;
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
const-string v4, "maxMemory = "
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(I)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;->i(Ljava/lang/String;Ljava/lang/String;)I
.line 157
div-int/lit8 v0, v0, 0x8
.line 158
new-instance v2, Lcom/viatech/common/ThumbnailCacheManager;
const/high16 v3, 0xa00000
invoke-direct {v2, v0, v3}, Lcom/viatech/common/ThumbnailCacheManager;-><init>(II)V
sput-object v2, Lcom/viatech/common/ThumbnailCacheManager;->sIns:Lcom/viatech/common/ThumbnailCacheManager;
.line 160
:cond_0
monitor-exit v1
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 162
:cond_1
sget-object v0, Lcom/viatech/common/ThumbnailCacheManager;->sIns:Lcom/viatech/common/ThumbnailCacheManager;
return-object v0
.line 160
:catchall_0
move-exception v0
:try_start_1
monitor-exit v1
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
throw v0
.end method
# virtual methods
.method public addThumbnailCacheListener(Lcom/viatech/common/ThumbnailCacheManager$ThumbnailCacheListener;)V
.locals 2
.prologue
.line 201
iget-object v1, p0, Lcom/viatech/common/ThumbnailCacheManager;->mThumbnailCacheListenerList:Ljava/util/List;
monitor-enter v1
.line 202
:try_start_0
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mThumbnailCacheListenerList:Ljava/util/List;
invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 203
monitor-exit v1
.line 204
return-void
.line 203
:catchall_0
move-exception v0
monitor-exit v1
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw v0
.end method
.method public clearTask()V
.locals 1
.prologue
.line 191
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mWorkThread:Lcom/viatech/common/util/WorkThread;
if-eqz v0, :cond_0
.line 192
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mWorkThread:Lcom/viatech/common/util/WorkThread;
invoke-virtual {v0}, Lcom/viatech/common/util/WorkThread;->cancelReqsList()V
.line 193
:cond_0
return-void
.end method
.method public getThumbnail(Ljava/lang/String;Ljava/lang/String;I)Landroid/graphics/Bitmap;
.locals 2
.prologue
.line 178
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mMemoryCache:Landroid/util/LruCache;
invoke-virtual {v0, p2}, Landroid/util/LruCache;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/graphics/Bitmap;
.line 179
if-eqz v0, :cond_0
invoke-virtual {v0}, Landroid/graphics/Bitmap;->isRecycled()Z
move-result v1
if-nez v1, :cond_0
.line 187
:goto_0
return-object v0
.line 182
:cond_0
new-instance v0, Lcom/viatech/common/ThumbnailCacheManager$BitmapDecodeReq;
invoke-direct {v0, p0, p1, p2, p3}, Lcom/viatech/common/ThumbnailCacheManager$BitmapDecodeReq;-><init>(Lcom/viatech/common/ThumbnailCacheManager;Ljava/lang/String;Ljava/lang/String;I)V
.line 183
iget-object v1, p0, Lcom/viatech/common/ThumbnailCacheManager;->mWorkThread:Lcom/viatech/common/util/WorkThread;
if-eqz v1, :cond_1
iget-object v1, p0, Lcom/viatech/common/ThumbnailCacheManager;->mWorkThread:Lcom/viatech/common/util/WorkThread;
invoke-virtual {v1, v0}, Lcom/viatech/common/util/WorkThread;->isDuplicateWorking(Lcom/viatech/common/util/Match4Req;)Z
move-result v1
if-nez v1, :cond_1
.line 184
iget-object v1, p0, Lcom/viatech/common/ThumbnailCacheManager;->mWorkThread:Lcom/viatech/common/util/WorkThread;
invoke-virtual {v1, v0}, Lcom/viatech/common/util/WorkThread;->addReq(Lcom/viatech/common/util/WorkReq;)V
.line 187
:cond_1
const/4 v0, 0x0
goto :goto_0
.end method
.method public hashKeyForDisk(Ljava/lang/String;)Ljava/lang/String;
.locals 2
.prologue
.line 265
: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 266
invoke-virtual {p1}, Ljava/lang/String;->getBytes()[B
move-result-object v1
invoke-virtual {v0, v1}, Ljava/security/MessageDigest;->update([B)V
.line 267
invoke-virtual {v0}, Ljava/security/MessageDigest;->digest()[B
move-result-object v0
invoke-direct {p0, v0}, Lcom/viatech/common/ThumbnailCacheManager;->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 271
:goto_0
return-object v0
.line 268
:catch_0
move-exception v0
.line 269
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 removeThumbnailCacheListener(Lcom/viatech/common/ThumbnailCacheManager$ThumbnailCacheListener;)V
.locals 2
.prologue
.line 212
iget-object v1, p0, Lcom/viatech/common/ThumbnailCacheManager;->mThumbnailCacheListenerList:Ljava/util/List;
monitor-enter v1
.line 213
:try_start_0
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mThumbnailCacheListenerList:Ljava/util/List;
invoke-interface {v0, p1}, Ljava/util/List;->remove(Ljava/lang/Object;)Z
.line 214
iget-object v0, p0, Lcom/viatech/common/ThumbnailCacheManager;->mThumbnailCacheListenerList:Ljava/util/List;
invoke-interface {v0}, Ljava/util/List;->size()I
move-result v0
if-nez v0, :cond_0
.line 215
invoke-direct {p0}, Lcom/viatech/common/ThumbnailCacheManager;->destory()V
.line 217
:cond_0
monitor-exit v1
.line 218
return-void
.line 217
:catchall_0
move-exception v0
monitor-exit v1
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw v0
.end method