diff options
Diffstat (limited to 'app/src/main/java/de/danoeh')
17 files changed, 280 insertions, 60 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/AppConfig.java b/app/src/main/java/de/danoeh/antennapod/AppConfig.java deleted file mode 100644 index 24f13d4a3..000000000 --- a/app/src/main/java/de/danoeh/antennapod/AppConfig.java +++ /dev/null @@ -1,7 +0,0 @@ -package de.danoeh.antennapod; - -public final class AppConfig { - /** Should be used when setting User-Agent header for HTTP-requests. */ - public final static String USER_AGENT = "AntennaPod/0.9.9.4"; - -} diff --git a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java index 4b709ab74..97eacc5c8 100644 --- a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java +++ b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java @@ -4,7 +4,6 @@ import android.app.Application; import android.content.Intent; import android.content.res.Configuration; -import de.danoeh.antennapod.core.asynctask.PicassoProvider; import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences; @@ -39,7 +38,8 @@ public class PodcastApp extends Application { singleton = this; LOGICAL_DENSITY = getResources().getDisplayMetrics().density; - PicassoProvider.setupPicassoInstance(this); + // PicassoProvider.setupPicassoInstance(this); + UpdateManager.init(this); UserPreferences.init(this); PlaybackPreferences.init(this); EventDistributor.getInstance(); diff --git a/app/src/main/java/de/danoeh/antennapod/UpdateManager.java b/app/src/main/java/de/danoeh/antennapod/UpdateManager.java new file mode 100644 index 000000000..75cf888fe --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/UpdateManager.java @@ -0,0 +1,82 @@ +package de.danoeh.antennapod; + + +import android.content.Context; +import android.content.SharedPreferences; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.util.Log; + +import java.io.File; +import java.util.List; + +import de.danoeh.antennapod.core.feed.Feed; +import de.danoeh.antennapod.core.feed.FeedImage; +import de.danoeh.antennapod.core.feed.FeedItem; +import de.danoeh.antennapod.core.storage.DBReader; +import de.danoeh.antennapod.core.storage.DBWriter; + +public class UpdateManager { + + public static final String TAG = UpdateManager.class.getSimpleName(); + + private static final String PREF_NAME = "app_version"; + private static final String KEY_VERSION_CODE = "version_code"; + + private static int currentVersionCode; + + private static Context context; + private static SharedPreferences prefs; + + public static void init(Context context) { + UpdateManager.context = context; + prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); + PackageManager pm = context.getPackageManager(); + try { + PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0); + currentVersionCode = info.versionCode; + } catch (PackageManager.NameNotFoundException e) { + Log.e(TAG, "Failed to obtain package info for package name: " + context.getPackageName(), e); + currentVersionCode = 0; + } + final int oldVersionCode = getStoredVersionCode(); + Log.d(TAG, "old: " + oldVersionCode + ", current: " + currentVersionCode); + if(oldVersionCode < currentVersionCode) { + onUpgrade(oldVersionCode, currentVersionCode); + setCurrentVersionCode(); + } + } + + public static int getCurrentVersionCode() { + return currentVersionCode; + } + + public static int getStoredVersionCode() { + return prefs.getInt(KEY_VERSION_CODE, -1); + } + + public static void setCurrentVersionCode() { + prefs.edit().putInt(KEY_VERSION_CODE, currentVersionCode).apply(); + } + + private static void onUpgrade(final int oldVersionCode, final int newVersionCode) { + if(oldVersionCode < 1030000) { + List<Feed> feeds = DBReader.getFeedList(context); + for(Feed podcast: feeds) { + List<FeedItem> episodes = DBReader.getFeedItemList(context, podcast); + for(FeedItem episode : episodes) { + FeedImage image = episode.getImage(); + if(image != null && image.isDownloaded() && image.getFile_url() != null) { + File imageFile = new File(image.getFile_url()); + if(imageFile.exists()) { + imageFile.delete(); + } + image.setFile_url(null); // calls setDownloaded(false) + DBWriter.setFeedImage(context, image); + } + } + } + } + } + +} diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index cae29db4b..28301313b 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -27,7 +27,8 @@ import android.widget.ImageButton; import android.widget.ListView; 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; @@ -556,9 +557,13 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc } txtvTitle.setText(media.getEpisodeTitle()); getSupportActionBar().setTitle(""); - Picasso.with(this) + Glide.with(this) .load(media.getImageUri()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(butShowCover); setNavButtonVisibility(); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java index 287ae3568..9114fdd1a 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/DefaultOnlineFeedViewActivity.java @@ -17,7 +17,8 @@ import android.widget.ListView; import android.widget.Spinner; 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; import org.jsoup.Jsoup; @@ -124,9 +125,13 @@ public class DefaultOnlineFeedViewActivity extends OnlineFeedViewActivity { subscribeButton = (Button) header.findViewById(R.id.butSubscribe); if (feed.getImage() != null && StringUtils.isNotBlank(feed.getImage().getDownload_url())) { - Picasso.with(this) + Glide.with(this) .load(feed.getImage().getDownload_url()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(cover); } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java index fae8baf65..a251801b5 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java @@ -14,19 +14,19 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.widget.AbsSpinner; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ImageView; -import android.widget.TextView; import android.widget.Spinner; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemSelectedListener; +import android.widget.TextView; import android.widget.Toast; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.joanzapata.android.iconify.Iconify; -import com.squareup.picasso.Picasso; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator; @@ -123,9 +123,13 @@ public class FeedInfoActivity extends ActionBarActivity { @Override public void run() { - Picasso.with(FeedInfoActivity.this) + Glide.with(FeedInfoActivity.this) .load(feed.getImageUri()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(imgvCover); } }); 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); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java index 3076f8136..fbd27779d 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java @@ -10,7 +10,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; @@ -80,8 +81,12 @@ public class CoverFragment extends Fragment implements public void run() { Context c = getActivity(); if (c != null) { - Picasso.with(c) + Glide.with(c) .load(media.getImageUri()) + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .dontAnimate() .into(imgvCover); } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java index 1679051f6..454fe35dd 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -11,7 +11,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.service.playback.PlaybackService; @@ -197,9 +198,13 @@ public class ExternalPlayerFragment extends Fragment { if (media != null) { txtvTitle.setText(media.getEpisodeTitle()); - Picasso.with(getActivity()) + Glide.with(getActivity()) .load(media.getImageUri()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(imgvCover); fragmentLayout.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java index e0ed3d02c..90bf623da 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -35,7 +35,8 @@ import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import java.util.List; @@ -336,9 +337,15 @@ public class ItemFragment extends Fragment implements LoaderManager.LoaderCallba txtvTitle.setText(item.getTitle()); txtvPublished.setText(DateUtils.formatDateTime(getActivity(), item.getPubDate().getTime(), DateUtils.FORMAT_ABBREV_ALL)); - Picasso.with(getActivity()).load(item.getImageUri()) - .fit() + Glide.with(getActivity()) + .load(item.getImageUri()) + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(imgvCover); + progbarDownload.setVisibility(View.INVISIBLE); if (item.hasMedia() && downloaderList != null) { for (Downloader downloader : downloaderList) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java index 2a1a7aaed..3321d6b84 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -31,9 +31,10 @@ import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.joanzapata.android.iconify.IconDrawable; import com.joanzapata.android.iconify.Iconify; -import com.squareup.picasso.Picasso; import org.apache.commons.lang3.Validate; @@ -46,7 +47,6 @@ import de.danoeh.antennapod.adapter.DefaultActionButtonCallback; import de.danoeh.antennapod.adapter.FeedItemlistAdapter; import de.danoeh.antennapod.core.asynctask.DownloadObserver; import de.danoeh.antennapod.core.asynctask.FeedRemover; -import de.danoeh.antennapod.core.asynctask.PicassoProvider; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator; import de.danoeh.antennapod.core.feed.EventDistributor; @@ -56,6 +56,7 @@ import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItemFilter; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.QueueEvent; +import de.danoeh.antennapod.core.glide.FastBlurTransformation; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.storage.DBReader; @@ -505,17 +506,25 @@ public class ItemlistFragment extends ListFragment { txtvTitle.setText(feed.getTitle()); txtvAuthor.setText(feed.getAuthor()); - Picasso.with(getActivity()) + Glide.with(getActivity()) .load(feed.getImageUri()) .placeholder(R.color.image_readability_tint) .error(R.color.image_readability_tint) - .transform(PicassoProvider.blurTransformation) - .resize(PicassoProvider.BLUR_IMAGE_SIZE, PicassoProvider.BLUR_IMAGE_SIZE) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .transform(new FastBlurTransformation(getActivity())) + .dontAnimate() .into(imgvBackground); - Picasso.with(getActivity()) + // https://github.com/bumptech/glide/issues/529 + imgvBackground.setColorFilter(R.color.image_readability_tint); + + Glide.with(getActivity()) .load(feed.getImageUri()) - .fit() + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .fitCenter() + .dontAnimate() .into(imgvCover); butShowInfo.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java index 3a8abcc40..b869d9c92 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java @@ -364,6 +364,26 @@ public class PreferenceController { return true; } }); + ui.findPreference(UserPreferences.PREF_IMAGE_CACHE_SIZE) + .setOnPreferenceChangeListener( + new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object o) { + if (o instanceof String) { + int newValue = Integer.valueOf((String) o) * 1024 * 1024; + if(newValue != UserPreferences.getImageCacheSize()) { + AlertDialog.Builder dialog = new AlertDialog.Builder(ui.getActivity()); + dialog.setTitle(android.R.string.dialog_alert_title); + dialog.setMessage(R.string.pref_restart_required); + dialog.setPositiveButton(android.R.string.ok, null); + dialog.show(); + } + return true; + } + return false; + } + } + ); buildSmartMarkAsPlayedPreference(); buildAutodownloadSelectedNetworsPreference(); setSelectedNetworksEnabled(UserPreferences |