[Android] BitmapCache: add missing synchronize
Thomas Guillem
git at videolan.org
Tue Oct 6 18:32:34 CEST 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct 6 17:31:45 2015 +0200| [3276a69a567b9e6185df7e857a087fac9212125c] | committer: Thomas Guillem
BitmapCache: add missing synchronize
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=3276a69a567b9e6185df7e857a087fac9212125c
---
vlc-android/src/org/videolan/vlc/util/BitmapCache.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/util/BitmapCache.java b/vlc-android/src/org/videolan/vlc/util/BitmapCache.java
index 6f278eb..f51c7e2 100644
--- a/vlc-android/src/org/videolan/vlc/util/BitmapCache.java
+++ b/vlc-android/src/org/videolan/vlc/util/BitmapCache.java
@@ -53,7 +53,7 @@ public class BitmapCache {
Set<SoftReference<Bitmap>> mCachedBitmaps;
Set<SoftReference<Bitmap>> mReusableBitmaps;
- public static BitmapCache getInstance() {
+ public synchronized static BitmapCache getInstance() {
if (mInstance == null)
mInstance = new BitmapCache();
return mInstance;
@@ -95,7 +95,7 @@ public class BitmapCache {
mCachedBitmaps = Collections.synchronizedSet(new HashSet<SoftReference<Bitmap>>());
}
- public Bitmap getBitmapFromMemCache(String key) {
+ public synchronized Bitmap getBitmapFromMemCache(String key) {
final CacheableBitmap cacheableBitmap = mMemCache.get(key);
if (cacheableBitmap == null)
return null;
@@ -117,7 +117,7 @@ public class BitmapCache {
return b;
}
- public void addBitmapToMemCache(String key, Bitmap bitmap) {
+ public synchronized void addBitmapToMemCache(String key, Bitmap bitmap) {
if (key != null && bitmap != null && getBitmapFromMemCache(key) == null) {
final CacheableBitmap cacheableBitmap = new CacheableBitmap(bitmap);
mMemCache.put(key, cacheableBitmap);
@@ -133,7 +133,7 @@ public class BitmapCache {
addBitmapToMemCache("res:" + resId, bitmap);
}
- public void clear() {
+ public synchronized void clear() {
mMemCache.evictAll();
mCachedBitmaps.clear();
}
More information about the Android
mailing list