From e5b7f12732794ec6f40a3dd2dda42cd7ddee5b76 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Wed, 6 Jan 2016 20:15:07 +0100 Subject: [PATCH] Indicate that episode cache is exhausted --- app/build.gradle | 4 ++-- .../activity/AudioplayerActivity.java | 5 +++++ .../antennapod/activity/MainActivity.java | 5 +++++ .../antennapod/adapter/NavListAdapter.java | 17 ++++++++++++++--- build.gradle | 2 +- .../antennapod/core/storage/DBReader.java | 3 +++ 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2fe94d576..d957d9833 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,8 +31,8 @@ dependencies { compile "io.reactivex:rxjava:$rxJavaVersion" // And ProGuard rules for RxJava! compile "com.artemzin.rxjava:proguard-rules:$rxJavaRulesVersion" - compile "com.joanzapata.iconify:android-iconify-fontawesome:$iconifyFontawesomeVersion" - compile "com.joanzapata.iconify:android-iconify-material:$iconifyFontawesomeVersion" + compile "com.joanzapata.iconify:android-iconify-fontawesome:$iconifyVersion" + compile "com.joanzapata.iconify:android-iconify-material:$iconifyVersion" compile("com.github.afollestad.material-dialogs:commons:$materialDialogsVersion") { transitive = true } 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 442515010..835ac29cd 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -841,6 +841,11 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc return (navDrawerData != null) ? navDrawerData.numNewItems : 0; } + @Override + public int getNumberOfDownloadedItems() { + return (navDrawerData != null) ? navDrawerData.numDownloadedItems : 0; + } + @Override public int getFeedCounter(long feedId) { return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0; diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 17cd5ace3..2181e7d2d 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -635,6 +635,11 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity return (navDrawerData != null) ? navDrawerData.numNewItems : 0; } + @Override + public int getNumberOfDownloadedItems() { + return (navDrawerData != null) ? navDrawerData.numDownloadedItems : 0; + } + @Override public int getFeedCounter(long feedId) { return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0; 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 183c1a44e..e984ba3be 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,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import com.bumptech.glide.Glide; -import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.joanzapata.iconify.Iconify; import com.joanzapata.iconify.widget.IconTextView; import org.apache.commons.lang3.ArrayUtils; @@ -208,7 +208,8 @@ public class NavListAdapter extends BaseAdapter holder.title.setText(title); - if (tags.get(position).equals(QueueFragment.TAG)) { + String tag = tags.get(position); + if (tag.equals(QueueFragment.TAG)) { int queueSize = itemAccess.getQueueSize(); if (queueSize > 0) { holder.count.setVisibility(View.VISIBLE); @@ -216,7 +217,7 @@ public class NavListAdapter extends BaseAdapter } else { holder.count.setVisibility(View.GONE); } - } else if (tags.get(position).equals(EpisodesFragment.TAG)) { + } else if (tag.equals(EpisodesFragment.TAG)) { int unreadItems = itemAccess.getNumberOfNewItems(); if (unreadItems > 0) { holder.count.setVisibility(View.VISIBLE); @@ -224,6 +225,15 @@ public class NavListAdapter extends BaseAdapter } else { holder.count.setVisibility(View.GONE); } + } else if(tag.equals(DownloadsFragment.TAG) && UserPreferences.isEnableAutodownload()) { + int epCacheSize = UserPreferences.getEpisodeCacheSize(); + if(itemAccess.getNumberOfDownloadedItems() >= epCacheSize) { + holder.count.setText("{md-disc-full 150%}"); + Iconify.addIcons(holder.count); + holder.count.setVisibility(View.VISIBLE); + } else { + holder.count.setVisibility(View.GONE); + } } else { holder.count.setVisibility(View.GONE); } @@ -316,6 +326,7 @@ public class NavListAdapter extends BaseAdapter int getSelectedItemIndex(); int getQueueSize(); int getNumberOfNewItems(); + int getNumberOfDownloadedItems(); int getFeedCounter(long feedId); } diff --git a/build.gradle b/build.gradle index 79cf2e3c5..aa2251121 100644 --- a/build.gradle +++ b/build.gradle @@ -47,8 +47,8 @@ project.ext { eventbusVersion = "2.4.0" flattr4jVersion = "2.12" glideVersion = "3.6.1" + iconifyVersion = "2.1.1" jsoupVersion = "1.7.3" - iconifyFontawesomeVersion = "2.1.1" materialDialogsVersion = "0.8.5.3@aar" recyclerviewFlexibledividerVersion = "1.2.6" rxAndroidVersion = "1.1.0" diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java index fe5b177ab..e8fd960f8 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java @@ -1015,6 +1015,8 @@ public final class DBReader { Collections.sort(feeds, comparator); int queueSize = adapter.getQueueSize(); int numNewItems = adapter.getNumberOfNewItems(); + int numDownloadedItems = adapter.getNumberOfDownloadedEpisodes(); + NavDrawerData result = new NavDrawerData(feeds, queueSize, numNewItems, feedCounters); adapter.close(); return result; @@ -1024,6 +1026,7 @@ public final class DBReader { public List feeds; public int queueSize; public int numNewItems; + public int numDownloadedItems; public LongIntMap feedCounters; public NavDrawerData(List feeds,