mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-02-01 03:06:48 +01:00
Clear glide when loading image manually
This commit is contained in:
parent
0bbeda9142
commit
052884e081
@ -21,6 +21,7 @@ import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||
|
||||
public class CoverLoader {
|
||||
private int resource = 0;
|
||||
private String uri;
|
||||
private String fallbackUri;
|
||||
private TextView txtvPlaceholder;
|
||||
@ -37,6 +38,11 @@ public class CoverLoader {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CoverLoader withResource(int resource) {
|
||||
this.resource = resource;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CoverLoader withFallbackUri(String uri) {
|
||||
fallbackUri = uri;
|
||||
return this;
|
||||
@ -66,6 +72,12 @@ public class CoverLoader {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (resource != 0) {
|
||||
imgvCover.setImageResource(resource);
|
||||
CoverTarget.setPlaceholderVisibility(txtvPlaceholder, textAndImageCombined);
|
||||
return;
|
||||
}
|
||||
|
||||
RequestOptions options = new RequestOptions()
|
||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||
.fitCenter()
|
||||
@ -106,15 +118,7 @@ public class CoverLoader {
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
TextView txtvPlaceholder = placeholder.get();
|
||||
if (txtvPlaceholder != null) {
|
||||
if (textAndImageCombined) {
|
||||
int bgColor = txtvPlaceholder.getContext().getResources().getColor(R.color.feed_text_bg);
|
||||
txtvPlaceholder.setBackgroundColor(bgColor);
|
||||
} else {
|
||||
txtvPlaceholder.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
setPlaceholderVisibility(placeholder.get(), textAndImageCombined);
|
||||
ImageView ivCover = cover.get();
|
||||
ivCover.setImageDrawable(resource);
|
||||
}
|
||||
@ -124,5 +128,16 @@ public class CoverLoader {
|
||||
ImageView ivCover = cover.get();
|
||||
ivCover.setImageDrawable(placeholder);
|
||||
}
|
||||
|
||||
static void setPlaceholderVisibility(TextView placeholder, boolean textAndImageCombined) {
|
||||
if (placeholder != null) {
|
||||
if (textAndImageCombined) {
|
||||
int bgColor = placeholder.getContext().getResources().getColor(R.color.feed_text_bg);
|
||||
placeholder.setBackgroundColor(bgColor);
|
||||
} else {
|
||||
placeholder.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -342,7 +342,7 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder>
|
||||
if (folder.isOpen) {
|
||||
holder.count.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
Glide.with(context).clear(holder.image);
|
||||
holder.image.setImageResource(ThemeUtils.getDrawableFromAttr(context, R.attr.ic_folder));
|
||||
holder.failure.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -118,13 +118,8 @@ public class SubscriptionsAdapter extends BaseAdapter implements AdapterView.OnI
|
||||
.withCoverView(holder.imageView)
|
||||
.load();
|
||||
} else {
|
||||
String resourceEntryName = mainActivityRef.get().getResources()
|
||||
.getResourceEntryName(ThemeUtils.getDrawableFromAttr(mainActivityRef.get(), R.attr.ic_folder));
|
||||
String iconUri = ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
|
||||
+ mainActivityRef.get().getPackageName() + "/raw/"
|
||||
+ resourceEntryName;
|
||||
new CoverLoader(mainActivityRef.get())
|
||||
.withUri(iconUri)
|
||||
.withResource(ThemeUtils.getDrawableFromAttr(mainActivityRef.get(), R.attr.ic_folder))
|
||||
.withPlaceholderView(holder.feedTitle, true)
|
||||
.withCoverView(holder.imageView)
|
||||
.load();
|
||||
|
Loading…
x
Reference in New Issue
Block a user