BitmapCounter.smali
.class public Lcom/facebook/imagepipeline/memory/BitmapCounter;
.super Ljava/lang/Object;
.source "SourceFile"
# instance fields
.field private mCount:I
.field private final mMaxCount:I
.field private final mMaxSize:I
.field private mSize:J
.field private final mUnpooledBitmapsReleaser:Lcom/facebook/common/references/ResourceReleaser;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lcom/facebook/common/references/ResourceReleaser<",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
.end field
# direct methods
.method public constructor <init>(II)V
.registers 6
.line 38
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const/4 v0, 0x1
const/4 v1, 0x0
if-lez p1, :cond_9
const/4 v2, 0x1
goto :goto_a
:cond_9
const/4 v2, 0x0
.line 39
:goto_a
invoke-static {v2}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Z)V
if-lez p2, :cond_10
goto :goto_11
:cond_10
const/4 v0, 0x0
.line 40
:goto_11
invoke-static {v0}, Lcom/facebook/common/internal/Preconditions;->checkArgument(Z)V
.line 41
iput p1, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mMaxCount:I
.line 42
iput p2, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mMaxSize:I
.line 43
new-instance p1, Lcom/facebook/imagepipeline/memory/BitmapCounter$1;
invoke-direct {p1, p0}, Lcom/facebook/imagepipeline/memory/BitmapCounter$1;-><init>(Lcom/facebook/imagepipeline/memory/BitmapCounter;)V
iput-object p1, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mUnpooledBitmapsReleaser:Lcom/facebook/common/references/ResourceReleaser;
return-void
.end method
# virtual methods
.method public declared-synchronized decrease(Landroid/graphics/Bitmap;)V
.registers 11
monitor-enter p0
.line 78
:try_start_1
invoke-static {p1}, Lcom/facebook/imageutils/BitmapUtil;->getSizeInBytes(Landroid/graphics/Bitmap;)I
move-result p1
.line 79
iget v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mCount:I
const/4 v1, 0x0
const/4 v2, 0x1
if-lez v0, :cond_d
const/4 v0, 0x1
goto :goto_e
:cond_d
const/4 v0, 0x0
:goto_e
const-string v3, "No bitmaps registered."
invoke-static {v0, v3}, Lcom/facebook/common/internal/Preconditions;->checkArgument(ZLjava/lang/Object;)V
int-to-long v3, p1
.line 80
iget-wide v5, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mSize:J
cmp-long v0, v3, v5
if-gtz v0, :cond_1c
const/4 v0, 0x1
goto :goto_1d
:cond_1c
const/4 v0, 0x0
:goto_1d
const-string v5, "Bitmap size bigger than the total registered size: %d, %d"
const/4 v6, 0x2
new-array v6, v6, [Ljava/lang/Object;
.line 83
invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object p1
aput-object p1, v6, v1
iget-wide v7, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mSize:J
.line 84
invoke-static {v7, v8}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p1
aput-object p1, v6, v2
.line 80
invoke-static {v0, v5, v6}, Lcom/facebook/common/internal/Preconditions;->checkArgument(ZLjava/lang/String;[Ljava/lang/Object;)V
.line 85
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mSize:J
sub-long/2addr v0, v3
iput-wide v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mSize:J
.line 86
iget p1, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mCount:I
sub-int/2addr p1, v2
iput p1, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mCount:I
:try_end_3d
.catchall {:try_start_1 .. :try_end_3d} :catchall_3f
.line 87
monitor-exit p0
return-void
:catchall_3f
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized getCount()I
.registers 2
monitor-enter p0
.line 93
:try_start_1
iget v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mCount:I
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_5
monitor-exit p0
return v0
:catchall_5
move-exception v0
monitor-exit p0
throw v0
.end method
.method public declared-synchronized getMaxCount()I
.registers 2
monitor-enter p0
.line 104
:try_start_1
iget v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mMaxCount:I
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_5
monitor-exit p0
return v0
:catchall_5
move-exception v0
monitor-exit p0
throw v0
.end method
.method public declared-synchronized getMaxSize()I
.registers 2
monitor-enter p0
.line 108
:try_start_1
iget v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mMaxSize:I
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_5
monitor-exit p0
return v0
:catchall_5
move-exception v0
monitor-exit p0
throw v0
.end method
.method public getReleaser()Lcom/facebook/common/references/ResourceReleaser;
.registers 2
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Lcom/facebook/common/references/ResourceReleaser<",
"Landroid/graphics/Bitmap;",
">;"
}
.end annotation
.line 112
iget-object v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mUnpooledBitmapsReleaser:Lcom/facebook/common/references/ResourceReleaser;
return-object v0
.end method
.method public declared-synchronized getSize()J
.registers 3
monitor-enter p0
.line 100
:try_start_1
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mSize:J
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_5
monitor-exit p0
return-wide v0
:catchall_5
move-exception v0
monitor-exit p0
throw v0
.end method
.method public declared-synchronized increase(Landroid/graphics/Bitmap;)Z
.registers 8
monitor-enter p0
.line 63
:try_start_1
invoke-static {p1}, Lcom/facebook/imageutils/BitmapUtil;->getSizeInBytes(Landroid/graphics/Bitmap;)I
move-result p1
.line 64
iget v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mCount:I
iget v1, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mMaxCount:I
if-ge v0, v1, :cond_24
iget-wide v0, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mSize:J
int-to-long v2, p1
add-long/2addr v0, v2
iget p1, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mMaxSize:I
int-to-long v4, p1
cmp-long p1, v0, v4
if-lez p1, :cond_17
goto :goto_24
.line 67
:cond_17
iget p1, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mCount:I
const/4 v0, 0x1
add-int/2addr p1, v0
iput p1, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mCount:I
.line 68
iget-wide v4, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mSize:J
add-long/2addr v4, v2
iput-wide v4, p0, Lcom/facebook/imagepipeline/memory/BitmapCounter;->mSize:J
:try_end_22
.catchall {:try_start_1 .. :try_end_22} :catchall_27
.line 69
monitor-exit p0
return v0
:cond_24
:goto_24
const/4 p1, 0x0
.line 65
monitor-exit p0
return p1
:catchall_27
move-exception p1
monitor-exit p0
throw p1
.end method