CacheUtil.smali
.class public Lcom/library/cache/CacheUtil;
.super Ljava/lang/Object;
.source "CacheUtil.java"
# interfaces
.implements Lcom/library/cache/CacheInterface;
# annotations
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">",
"Ljava/lang/Object;",
"Lcom/library/cache/CacheInterface<",
"TT;>;"
}
.end annotation
# instance fields
.field private mLruCache:Landroid/util/LruCache;
.annotation system Ldalvik/annotation/Signature;
value = {
"Landroid/util/LruCache<",
"Ljava/lang/Integer;",
"TT;>;"
}
.end annotation
.end field
.field private mSoftCache:Landroid/util/SparseArray;
.annotation system Ldalvik/annotation/Signature;
value = {
"Landroid/util/SparseArray<",
"Ljava/lang/ref/SoftReference<",
"TT;>;>;"
}
.end annotation
.end field
.field private mUseCache:Z
# direct methods
.method static constructor <clinit>()V
.registers 1
return-void
.end method
.method public constructor <init>()V
.registers 2
.line 34
.local p0, "this":Lcom/library/cache/CacheUtil;, "Lcom/library/cache/CacheUtil<TT;>;"
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 19
const/4 v0, 0x1
iput-boolean v0, p0, Lcom/library/cache/CacheUtil;->mUseCache:Z
.line 35
invoke-direct {p0}, Lcom/library/cache/CacheUtil;->initLruCache()V
.line 36
return-void
.end method
.method private initLruCache()V
.registers 3
.line 48
.local p0, "this":Lcom/library/cache/CacheUtil;, "Lcom/library/cache/CacheUtil<TT;>;"
new-instance v0, Lcom/library/cache/CacheUtil$1;
const/high16 v1, 0x200000
invoke-direct {v0, p0, v1}, Lcom/library/cache/CacheUtil$1;-><init>(Lcom/library/cache/CacheUtil;I)V
iput-object v0, p0, Lcom/library/cache/CacheUtil;->mLruCache:Landroid/util/LruCache;
.line 54
return-void
.end method
# virtual methods
.method public clean()V
.registers 2
.line 82
.local p0, "this":Lcom/library/cache/CacheUtil;, "Lcom/library/cache/CacheUtil<TT;>;"
iget-object v0, p0, Lcom/library/cache/CacheUtil;->mLruCache:Landroid/util/LruCache;
invoke-virtual {v0}, Landroid/util/LruCache;->evictAll()V
.line 83
return-void
.end method
.method public get(I)Ljava/lang/Object;
.registers 4
.param p1, "position" # I
.annotation system Ldalvik/annotation/Signature;
value = {
"(I)TT;"
}
.end annotation
.line 66
.local p0, "this":Lcom/library/cache/CacheUtil;, "Lcom/library/cache/CacheUtil<TT;>;"
iget-boolean v0, p0, Lcom/library/cache/CacheUtil;->mUseCache:Z
if-nez v0, :cond_6
.line 67
const/4 v0, 0x0
return-object v0
.line 69
:cond_6
iget-object v0, p0, Lcom/library/cache/CacheUtil;->mLruCache:Landroid/util/LruCache;
invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
invoke-virtual {v0, v1}, Landroid/util/LruCache;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v0
return-object v0
.end method
.method public isCacheable(Z)V
.registers 2
.param p1, "b" # Z
.line 44
.local p0, "this":Lcom/library/cache/CacheUtil;, "Lcom/library/cache/CacheUtil<TT;>;"
iput-boolean p1, p0, Lcom/library/cache/CacheUtil;->mUseCache:Z
.line 45
return-void
.end method
.method public put(ILjava/lang/Object;)V
.registers 5
.param p1, "position" # I
.annotation system Ldalvik/annotation/Signature;
value = {
"(ITT;)V"
}
.end annotation
.line 58
.local p0, "this":Lcom/library/cache/CacheUtil;, "Lcom/library/cache/CacheUtil<TT;>;"
.local p2, "t":Ljava/lang/Object;, "TT;"
iget-boolean v0, p0, Lcom/library/cache/CacheUtil;->mUseCache:Z
if-nez v0, :cond_5
.line 59
return-void
.line 61
:cond_5
iget-object v0, p0, Lcom/library/cache/CacheUtil;->mLruCache:Landroid/util/LruCache;
invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
invoke-virtual {v0, v1, p2}, Landroid/util/LruCache;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
.line 62
return-void
.end method
.method public remove(I)V
.registers 4
.param p1, "position" # I
.line 74
.local p0, "this":Lcom/library/cache/CacheUtil;, "Lcom/library/cache/CacheUtil<TT;>;"
iget-boolean v0, p0, Lcom/library/cache/CacheUtil;->mUseCache:Z
if-nez v0, :cond_5
.line 75
return-void
.line 77
:cond_5
iget-object v0, p0, Lcom/library/cache/CacheUtil;->mLruCache:Landroid/util/LruCache;
invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
invoke-virtual {v0, v1}, Landroid/util/LruCache;->remove(Ljava/lang/Object;)Ljava/lang/Object;
.line 78
return-void
.end method