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;
|
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||||
|
|
||||||
public class CoverLoader {
|
public class CoverLoader {
|
||||||
|
private int resource = 0;
|
||||||
private String uri;
|
private String uri;
|
||||||
private String fallbackUri;
|
private String fallbackUri;
|
||||||
private TextView txtvPlaceholder;
|
private TextView txtvPlaceholder;
|
||||||
@ -37,6 +38,11 @@ public class CoverLoader {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CoverLoader withResource(int resource) {
|
||||||
|
this.resource = resource;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public CoverLoader withFallbackUri(String uri) {
|
public CoverLoader withFallbackUri(String uri) {
|
||||||
fallbackUri = uri;
|
fallbackUri = uri;
|
||||||
return this;
|
return this;
|
||||||
@ -66,6 +72,12 @@ public class CoverLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
|
if (resource != 0) {
|
||||||
|
imgvCover.setImageResource(resource);
|
||||||
|
CoverTarget.setPlaceholderVisibility(txtvPlaceholder, textAndImageCombined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RequestOptions options = new RequestOptions()
|
RequestOptions options = new RequestOptions()
|
||||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||||
.fitCenter()
|
.fitCenter()
|
||||||
@ -106,15 +118,7 @@ public class CoverLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||||
TextView txtvPlaceholder = placeholder.get();
|
setPlaceholderVisibility(placeholder.get(), textAndImageCombined);
|
||||||
if (txtvPlaceholder != null) {
|
|
||||||
if (textAndImageCombined) {
|
|
||||||
int bgColor = txtvPlaceholder.getContext().getResources().getColor(R.color.feed_text_bg);
|
|
||||||
txtvPlaceholder.setBackgroundColor(bgColor);
|
|
||||||
} else {
|
|
||||||
txtvPlaceholder.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImageView ivCover = cover.get();
|
ImageView ivCover = cover.get();
|
||||||
ivCover.setImageDrawable(resource);
|
ivCover.setImageDrawable(resource);
|
||||||
}
|
}
|
||||||
@ -124,5 +128,16 @@ public class CoverLoader {
|
|||||||
ImageView ivCover = cover.get();
|
ImageView ivCover = cover.get();
|
||||||
ivCover.setImageDrawable(placeholder);
|
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) {
|
if (folder.isOpen) {
|
||||||
holder.count.setVisibility(View.GONE);
|
holder.count.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
Glide.with(context).clear(holder.image);
|
||||||
holder.image.setImageResource(ThemeUtils.getDrawableFromAttr(context, R.attr.ic_folder));
|
holder.image.setImageResource(ThemeUtils.getDrawableFromAttr(context, R.attr.ic_folder));
|
||||||
holder.failure.setVisibility(View.GONE);
|
holder.failure.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -118,13 +118,8 @@ public class SubscriptionsAdapter extends BaseAdapter implements AdapterView.OnI
|
|||||||
.withCoverView(holder.imageView)
|
.withCoverView(holder.imageView)
|
||||||
.load();
|
.load();
|
||||||
} else {
|
} 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())
|
new CoverLoader(mainActivityRef.get())
|
||||||
.withUri(iconUri)
|
.withResource(ThemeUtils.getDrawableFromAttr(mainActivityRef.get(), R.attr.ic_folder))
|
||||||
.withPlaceholderView(holder.feedTitle, true)
|
.withPlaceholderView(holder.feedTitle, true)
|
||||||
.withCoverView(holder.imageView)
|
.withCoverView(holder.imageView)
|
||||||
.load();
|
.load();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user