53 lines
1.8 KiB
Java
53 lines
1.8 KiB
Java
package cn.com.magnity.magnitycx.sdk;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.os.Build;
|
|
import android.support.v4.util.LruCache;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class LruCacheManager {
|
|
private static final int CACHE_SIZE = 10485760;
|
|
private static LruCacheManager instance_;
|
|
private LruCache<String, Bitmap> memCache_;
|
|
|
|
private LruCacheManager() {
|
|
}
|
|
|
|
public static LruCacheManager getInstance() {
|
|
if (instance_ == null) {
|
|
instance_ = new LruCacheManager();
|
|
instance_.init();
|
|
}
|
|
return instance_;
|
|
}
|
|
|
|
private void init() {
|
|
int maxMemory = (int) Runtime.getRuntime().maxMemory();
|
|
int cacheSize = CACHE_SIZE;
|
|
if (CACHE_SIZE > maxMemory / 8) {
|
|
cacheSize = maxMemory / 8;
|
|
}
|
|
this.memCache_ = new LruCache<String, Bitmap>(cacheSize) { // from class: cn.com.magnity.magnitycx.sdk.LruCacheManager.1
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // android.support.v4.util.LruCache
|
|
public int sizeOf(String key, Bitmap bitmap) {
|
|
return Build.VERSION.SDK_INT >= 12 ? bitmap.getByteCount() : bitmap.getRowBytes() * bitmap.getHeight();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // android.support.v4.util.LruCache
|
|
public void entryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue) {
|
|
super.entryRemoved(evicted, (boolean) key, oldValue, newValue);
|
|
}
|
|
};
|
|
}
|
|
|
|
public synchronized Bitmap put(String key, Bitmap value) {
|
|
return this.memCache_.put(key, value);
|
|
}
|
|
|
|
public synchronized Bitmap get(String key) {
|
|
return this.memCache_.get(key);
|
|
}
|
|
}
|