|
9 | 9 | import com.bumptech.glide.request.animation.GlideAnimation;
|
10 | 10 | import com.bumptech.glide.request.target.SimpleTarget;
|
11 | 11 |
|
12 |
| -import java.util.HashMap; |
13 |
| -import java.util.Map; |
14 |
| - |
15 | 12 | /**
|
16 | 13 | * Cache wrapper around the Glide image loader.
|
| 14 | + * 29.07.16: for now, the second layer cache is removed, caching is handled by Glide. |
17 | 15 | * <p>
|
18 | 16 | * Created by aronhomberg on 26.07.16.
|
19 | 17 | */
|
20 | 18 | public class RemoteImageLoader {
|
21 | 19 |
|
22 |
| - private static Map<String, Bitmap> bitmapCache = new HashMap<>(); |
23 |
| - |
24 | 20 | public static void load(final String url, int pxWidth, int pxHeight,
|
25 | 21 | 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 | + }); |
43 | 33 | }
|
44 | 34 |
|
45 | 35 | public interface Callback {
|
|
0 commit comments