Prevent NPE b/c of race condition

This commit is contained in:
Martin Fietz 2015-08-02 18:24:32 +02:00
parent 5f1c78b4f4
commit 5f0ddbc15d
2 changed files with 12 additions and 6 deletions

View File

@ -177,13 +177,16 @@ public class AllEpisodesListAdapter extends BaseAdapter {
@Override @Override
public void onLoadFailed(Exception e, Drawable errorDrawable) { public void onLoadFailed(Exception e, Drawable errorDrawable) {
if(fallback.get() != null && placeholder.get() != null && cover.get() != null) { Uri fallbackUri = fallback.get();
TextView txtvPlaceholder = placeholder.get();
ImageView imgvCover = cover.get();
if(fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
Glide.with(context) Glide.with(context)
.load(fallback.get()) .load(fallbackUri)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(DiskCacheStrategy.SOURCE)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(new CoverTarget(null, placeholder.get(), cover.get())); .into(new CoverTarget(null, txtvPlaceholder, imgvCover));
} }
} }

View File

@ -182,13 +182,16 @@ public class QueueListAdapter extends BaseAdapter {
@Override @Override
public void onLoadFailed(Exception e, Drawable errorDrawable) { public void onLoadFailed(Exception e, Drawable errorDrawable) {
if(fallback.get() != null && placeholder.get() != null && cover.get() != null) { Uri fallbackUri = fallback.get();
TextView txtvPlaceholder = placeholder.get();
ImageView imgvCover = cover.get();
if(fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
Glide.with(context) Glide.with(context)
.load(fallback.get()) .load(fallbackUri)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(DiskCacheStrategy.SOURCE)
.fitCenter() .fitCenter()
.dontAnimate() .dontAnimate()
.into(new CoverTarget(null, placeholder.get(), cover.get())); .into(new CoverTarget(null, txtvPlaceholder, imgvCover));
} }
} }