Skip to content

Commit af5be39

Browse files
fess89omkarmoghe
authored andcommitted
Removed the second layer cache from RemoteImageLoader (#335)
1 parent 95330cb commit af5be39

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

app/src/main/java/com/omkarmoghe/pokemap/helpers/RemoteImageLoader.java

+12-22
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,27 @@
99
import com.bumptech.glide.request.animation.GlideAnimation;
1010
import com.bumptech.glide.request.target.SimpleTarget;
1111

12-
import java.util.HashMap;
13-
import java.util.Map;
14-
1512
/**
1613
* Cache wrapper around the Glide image loader.
14+
* 29.07.16: for now, the second layer cache is removed, caching is handled by Glide.
1715
* <p>
1816
* Created by aronhomberg on 26.07.16.
1917
*/
2018
public class RemoteImageLoader {
2119

22-
private static Map<String, Bitmap> bitmapCache = new HashMap<>();
23-
2420
public static void load(final String url, int pxWidth, int pxHeight,
2521
Drawable placeholderDrawable, Context context, final Callback onFetch) {
26-
// ultra-fast cache reply
27-
if (bitmapCache.containsKey(url)) {
28-
onFetch.onFetch(bitmapCache.get(url));
29-
} else {
30-
Glide.with(context).load(url)
31-
.asBitmap()
32-
.skipMemoryCache(false)
33-
.placeholder(placeholderDrawable)
34-
.diskCacheStrategy(DiskCacheStrategy.ALL)
35-
.into(new SimpleTarget<Bitmap>(pxWidth, pxHeight) {
36-
@Override
37-
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
38-
bitmapCache.put(url, bitmap);
39-
onFetch.onFetch(bitmap);
40-
}
41-
});
42-
}
22+
Glide.with(context).load(url)
23+
.asBitmap()
24+
.skipMemoryCache(false)
25+
.placeholder(placeholderDrawable)
26+
.diskCacheStrategy(DiskCacheStrategy.ALL)
27+
.into(new SimpleTarget<Bitmap>(pxWidth, pxHeight) {
28+
@Override
29+
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
30+
onFetch.onFetch(bitmap);
31+
}
32+
});
4333
}
4434

4535
public interface Callback {

0 commit comments

Comments
 (0)