mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Further improve image loading, and remove unused code.
This commit is contained in:
parent
a9d58d4757
commit
85b15cd1c1
3 changed files with 18 additions and 21 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package fr.free.nrw.commons;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.LruCache;
|
||||
import android.util.AttributeSet;
|
||||
|
|
@ -27,15 +28,16 @@ public class MediaWikiImageView extends SimpleDraweeView {
|
|||
if (currentThumbnailTask != null) {
|
||||
currentThumbnailTask.cancel(true);
|
||||
}
|
||||
setImageURI((String) null);
|
||||
if(media == null) {
|
||||
setImageURI((String) null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (thumbnailUrlCache.get(media.getFilename()) != null) {
|
||||
setImageUrl(thumbnailUrlCache.get(media.getFilename()));
|
||||
} else {
|
||||
currentThumbnailTask = new ThumbnailFetchTask();
|
||||
setImageURI((String) null);
|
||||
currentThumbnailTask = new ThumbnailFetchTask(media);
|
||||
currentThumbnailTask.execute(media.getFilename());
|
||||
}
|
||||
}
|
||||
|
|
@ -53,11 +55,16 @@ public class MediaWikiImageView extends SimpleDraweeView {
|
|||
}
|
||||
|
||||
private class ThumbnailFetchTask extends MediaThumbnailFetchTask {
|
||||
ThumbnailFetchTask(@NonNull Media media) {
|
||||
super(media);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
if (isCancelled()) {
|
||||
return;
|
||||
}
|
||||
thumbnailUrlCache.put(media.getFilename(), result);
|
||||
setImageUrl(result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue