Implemented miroguide thumbnail download in FeedImageLoader
This commit is contained in:
parent
24775b9163
commit
a0cedbcbed
@ -133,6 +133,28 @@ public class FeedImageLoader {
|
|||||||
target.setImageResource(R.drawable.default_cover);
|
target.setImageResource(R.drawable.default_cover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadMiroGuideThumbnail(MiroChannel channel, ImageView target) {
|
||||||
|
if (channel.getThumbnailUrl() != null) {
|
||||||
|
Bitmap bitmap = getBitmapFromThumbnailCache(channel.getThumbnailUrl());
|
||||||
|
if (bitmap != null) {
|
||||||
|
boolean isInDiskCache = false;
|
||||||
|
try {
|
||||||
|
isInDiskCache = isInThumbnailDiskCache(channel.getThumbnailUrl());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e(TAG, "Error when trying to read disk cache");
|
||||||
|
}
|
||||||
|
if (isInDiskCache) {
|
||||||
|
new MiroGuideDiskCacheLoader(target, channel, LENGTH_BASE_THUMBNAIL).executeAsync();
|
||||||
|
} else {
|
||||||
|
new MiroGuideThumbnailDownloader(target, channel, LENGTH_BASE_THUMBNAIL).executeAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
target.setImageResource(R.drawable.default_cover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void wipeImageCache() {
|
public void wipeImageCache() {
|
||||||
coverCache.evictAll();
|
coverCache.evictAll();
|
||||||
@ -162,6 +184,11 @@ public class FeedImageLoader {
|
|||||||
public void addBitmapToCoverCache(String key, Bitmap bitmap) {
|
public void addBitmapToCoverCache(String key, Bitmap bitmap) {
|
||||||
coverCache.put(key, bitmap);
|
coverCache.put(key, bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInThumbnailDiskCache(String key) throws IOException {
|
||||||
|
DiskLruCache cache = openThubmnailDiskCache();
|
||||||
|
return cache.get(key) != null;
|
||||||
|
}
|
||||||
|
|
||||||
class FeedImageDecodeWorkerTask extends BitmapDecodeWorkerTask {
|
class FeedImageDecodeWorkerTask extends BitmapDecodeWorkerTask {
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class MiroGuideThumbnailDownloader extends BitmapDecodeWorkerTask {
|
|||||||
output.write(inputBuffer, 0, count);
|
output.write(inputBuffer, 0, count);
|
||||||
}
|
}
|
||||||
output.close();
|
output.close();
|
||||||
|
if (AppConfig.DEBUG) Log.d(TAG, "MiroGuide thumbnail downloaded");
|
||||||
// Get a smaller version of the bitmap and store it inside the
|
// Get a smaller version of the bitmap and store it inside the
|
||||||
// LRU
|
// LRU
|
||||||
// Cache
|
// Cache
|
||||||
|
Loading…
x
Reference in New Issue
Block a user