diff options
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/adapter')
6 files changed, 108 insertions, 23 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesListAdapter.java index bc3d3abbc..f67bb9d7e 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesListAdapter.java @@ -11,7 +11,13 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.bumptech.glide.load.resource.drawable.GlideDrawable; +import com.bumptech.glide.request.animation.GlideAnimation; +import com.bumptech.glide.request.target.GlideDrawableImageViewTarget; + +import java.lang.ref.WeakReference; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; @@ -72,6 +78,7 @@ public class AllEpisodesListAdapter extends BaseAdapter { .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.new_episodes_listitem, parent, false); + holder.feed = (TextView) convertView.findViewById(R.id.txtvImage); holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); holder.pubDate = (TextView) convertView .findViewById(R.id.txtvPublished); @@ -89,6 +96,8 @@ public class AllEpisodesListAdapter extends BaseAdapter { holder = (Holder) convertView.getTag(); } + holder.feed.setVisibility(View.VISIBLE); + holder.feed.setText(item.getFeed().getTitle()); holder.title.setText(item.getTitle()); holder.pubDate.setText(DateUtils.formatDateTime(context, item.getPubDate().getTime(), DateUtils.FORMAT_ABBREV_ALL)); if (showOnlyNewEpisodes || false == item.isNew()) { @@ -141,14 +150,35 @@ public class AllEpisodesListAdapter extends BaseAdapter { holder.butSecondary.setTag(item); holder.butSecondary.setOnClickListener(secondaryActionListener); - Picasso.with(context) + Glide.with(context) .load(item.getImageUri()) - .fit() - .into(holder.imageView); + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() + .into(new CustomTarget(holder.feed, holder.imageView)); return convertView; } + private class CustomTarget extends GlideDrawableImageViewTarget { + + private final WeakReference<TextView> mPlaceholder; + + public CustomTarget(TextView placeholder, ImageView imageView) { + super(imageView); + mPlaceholder = new WeakReference<TextView>(placeholder); + } + + @Override + public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) { + super.onResourceReady(drawable, anim); + TextView txtvPlaceholder = mPlaceholder.get(); + if(txtvPlaceholder != null) { + txtvPlaceholder.setVisibility(View.INVISIBLE); + } + } + } + private View.OnClickListener secondaryActionListener = new View.OnClickListener() { @Override public void onClick(View v) { @@ -159,6 +189,7 @@ public class AllEpisodesListAdapter extends BaseAdapter { static class Holder { + TextView feed; TextView title; TextView pubDate; View statusUnread; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java index 15e0a7a33..0cf761503 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadedEpisodesListAdapter.java @@ -10,7 +10,8 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; @@ -88,9 +89,13 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter { holder.butSecondary.setOnClickListener(secondaryActionListener); - Picasso.with(context) + Glide.with(context) .load(item.getImageUri()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(holder.imageView); return convertView; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index 444d08da9..a063ad9b1 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -15,7 +15,8 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import org.apache.commons.lang3.ArrayUtils; @@ -259,9 +260,13 @@ public class NavListAdapter extends BaseAdapter holder = (FeedHolder) convertView.getTag(); } - Picasso.with(context) + Glide.with(context) .load(feed.getImageUri()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(holder.image); holder.title.setText(feed.getTitle()); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/QueueListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/QueueListAdapter.java index 431b645c6..51a4112ce 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/QueueListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/QueueListAdapter.java @@ -11,7 +11,13 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.bumptech.glide.load.resource.drawable.GlideDrawable; +import com.bumptech.glide.request.animation.GlideAnimation; +import com.bumptech.glide.request.target.GlideDrawableImageViewTarget; + +import java.lang.ref.WeakReference; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItem; @@ -76,6 +82,7 @@ public class QueueListAdapter extends BaseAdapter { convertView = inflater.inflate(R.layout.queue_listitem, parent, false); holder.dragHandle = (ImageView) convertView.findViewById(R.id.drag_handle); + holder.feed = (TextView) convertView.findViewById(R.id.txtvImage); holder.imageView = (ImageView) convertView.findViewById(R.id.imgvImage); holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); holder.pubDate = (TextView) convertView.findViewById(R.id.txtvPubDate); @@ -98,10 +105,11 @@ public class QueueListAdapter extends BaseAdapter { holder.dragHandle.setVisibility(View.VISIBLE); } + holder.feed.setText(item.getFeed().getTitle()); + holder.title.setText(item.getTitle()); FeedMedia media = item.getMedia(); - holder.title.setText(item.getTitle()); String pubDate = DateUtils.formatDateTime(context, item.getPubDate().getTime(), DateUtils.FORMAT_ABBREV_ALL); holder.pubDate.setText(pubDate.replace(" ", "\n")); @@ -144,14 +152,35 @@ public class QueueListAdapter extends BaseAdapter { holder.butSecondary.setTag(item); holder.butSecondary.setOnClickListener(secondaryActionListener); - Picasso.with(context) + Glide.with(context) .load(item.getImageUri()) - .fit() - .into(holder.imageView); + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() + .into(new CustomTarget(holder.feed, holder.imageView)); return convertView; } + private class CustomTarget extends GlideDrawableImageViewTarget { + + private final WeakReference<TextView> mPlaceholder; + + public CustomTarget(TextView placeholder, ImageView imageView) { + super(imageView); + mPlaceholder = new WeakReference<TextView>(placeholder); + } + + @Override + public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) { + super.onResourceReady(drawable, anim); + TextView txtvPlaceholder = mPlaceholder.get(); + if(txtvPlaceholder != null) { + txtvPlaceholder.setVisibility(View.INVISIBLE); + } + } + } + private View.OnClickListener secondaryActionListener = new View.OnClickListener() { @Override public void onClick(View v) { @@ -164,6 +193,7 @@ public class QueueListAdapter extends BaseAdapter { static class Holder { ImageView dragHandle; ImageView imageView; + TextView feed; TextView title; TextView pubDate; TextView progressLeft; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java index cedce7903..8c1464e97 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java @@ -8,7 +8,8 @@ import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.Feed; @@ -73,9 +74,13 @@ public class SearchlistAdapter extends BaseAdapter { holder.title.setText(feed.getTitle()); holder.subtitle.setVisibility(View.GONE); - Picasso.with(context) + Glide.with(context) .load(feed.getImageUri()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(holder.cover); } else if (component.getClass() == FeedItem.class) { @@ -86,9 +91,13 @@ public class SearchlistAdapter extends BaseAdapter { holder.subtitle.setText(result.getSubtitle()); } - Picasso.with(context) + Glide.with(context) .load(item.getFeed().getImageUri()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(holder.cover); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java index b85709c5e..b9993b455 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java @@ -8,7 +8,8 @@ import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import org.apache.commons.lang3.StringUtils; @@ -49,9 +50,13 @@ public class PodcastListAdapter extends ArrayAdapter<GpodnetPodcast> { } if (StringUtils.isNotBlank(podcast.getLogoUrl())) { - Picasso.with(convertView.getContext()) + Glide.with(convertView.getContext()) .load(podcast.getLogoUrl()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(holder.image); } |