Fix weird behavior in CoverLoader
If you had an episode in the queue without a cover, it first showed the placeholder text. After scrolling, the placeholder text was hidden and then there was just nothing at all. This was inconsistent and confusing. Now, always shows the placeholder (while loading and on error), making sure to update visibility.
This commit is contained in:
parent
2f0c627b15
commit
499db625c0
@ -24,7 +24,6 @@ public class CoverLoader {
|
|||||||
private TextView txtvPlaceholder;
|
private TextView txtvPlaceholder;
|
||||||
private ImageView imgvCover;
|
private ImageView imgvCover;
|
||||||
private MainActivity activity;
|
private MainActivity activity;
|
||||||
private int errorResource = -1;
|
|
||||||
|
|
||||||
public CoverLoader(MainActivity activity) {
|
public CoverLoader(MainActivity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
@ -45,11 +44,6 @@ public class CoverLoader {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoverLoader withError(int errorResource) {
|
|
||||||
this.errorResource = errorResource;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoverLoader withPlaceholderView(TextView placeholderView) {
|
public CoverLoader withPlaceholderView(TextView placeholderView) {
|
||||||
txtvPlaceholder = placeholderView;
|
txtvPlaceholder = placeholderView;
|
||||||
return this;
|
return this;
|
||||||
@ -61,10 +55,6 @@ public class CoverLoader {
|
|||||||
.fitCenter()
|
.fitCenter()
|
||||||
.dontAnimate();
|
.dontAnimate();
|
||||||
|
|
||||||
if (errorResource != -1) {
|
|
||||||
options = options.error(errorResource);
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestBuilder<Drawable> builder = Glide.with(activity)
|
RequestBuilder<Drawable> builder = Glide.with(activity)
|
||||||
.load(uri)
|
.load(uri)
|
||||||
.apply(options);
|
.apply(options);
|
||||||
@ -84,6 +74,9 @@ public class CoverLoader {
|
|||||||
|
|
||||||
public CoverTarget(TextView txtvPlaceholder, ImageView imgvCover) {
|
public CoverTarget(TextView txtvPlaceholder, ImageView imgvCover) {
|
||||||
super(imgvCover);
|
super(imgvCover);
|
||||||
|
if (txtvPlaceholder != null) {
|
||||||
|
txtvPlaceholder.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
placeholder = new WeakReference<>(txtvPlaceholder);
|
placeholder = new WeakReference<>(txtvPlaceholder);
|
||||||
cover = new WeakReference<>(imgvCover);
|
cover = new WeakReference<>(imgvCover);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,6 @@ public class SubscriptionsAdapter extends BaseAdapter implements AdapterView.OnI
|
|||||||
.withUri(feed.getImageLocation())
|
.withUri(feed.getImageLocation())
|
||||||
.withPlaceholderView(holder.feedTitle)
|
.withPlaceholderView(holder.feedTitle)
|
||||||
.withCoverView(holder.imageView)
|
.withCoverView(holder.imageView)
|
||||||
.withError(R.color.light_gray)
|
|
||||||
.load();
|
.load();
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user