-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Externalized memory caching, only insert into memory if smaller than …
…1/4 of cache size to reduce flooding
- Loading branch information
Showing
3 changed files
with
47 additions
and
15 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
library/src/com/handlerexploit/common/utils/BitmapMemoryLruCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.handlerexploit.common.utils; | ||
|
||
import com.handlerexploit.prime.Configuration; | ||
import com.handlerexploit.prime.utils.ImageManager; | ||
|
||
import android.graphics.Bitmap; | ||
|
||
public class BitmapMemoryLruCache extends LruCache<String, Bitmap> implements ImageManager.MemoryCache { | ||
|
||
public BitmapMemoryLruCache() { | ||
super(Configuration.MEM_CACHE_SIZE_KB * 1024); | ||
} | ||
|
||
@Override | ||
public int sizeOf(String key, Bitmap value) { | ||
return value.getRowBytes() * value.getHeight(); | ||
} | ||
|
||
@Override | ||
public Bitmap getCached(String key) { | ||
return get(key); | ||
} | ||
|
||
@Override | ||
public Bitmap putCached(String key, Bitmap value) { | ||
return put(key, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters