diff options
author | Martin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de> | 2015-05-08 16:02:02 +0200 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-05-19 11:58:37 +0200 |
commit | 6f5d23c55743bd98800148c943880ce00d04441a (patch) | |
tree | 8ef9f5115d47bfba8173b9834475bdf61c7efc10 /app/src/main/java/de | |
parent | 406dab0a24543f4332b338f64689948cdc96c3bc (diff) | |
download | AntennaPod-6f5d23c55743bd98800148c943880ce00d04441a.zip |
Order feeds by number of unread items (descending)
Diffstat (limited to 'app/src/main/java/de')
4 files changed, 31 insertions, 17 deletions
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 213afb57a..8f18235c7 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -706,5 +706,10 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc public int getNumberOfUnreadItems() { return (navDrawerData != null) ? navDrawerData.numUnreadItems : 0; } + + @Override + public int getNumberOfUnreadFeedItems(long feedId) { + return (navDrawerData != null) ? navDrawerData.numUnreadFeedItems.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 dfecfc837..842dbcc9d 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -511,6 +511,11 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity return (navDrawerData != null) ? navDrawerData.numUnreadItems : 0; } + @Override + public int getNumberOfUnreadFeedItems(long feedId) { + return (navDrawerData != null) ? navDrawerData.numUnreadFeedItems.get(feedId) : 0; + } + }; private void loadData() { 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 6cde97148..818f662cd 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -27,7 +27,6 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.fragment.AddFeedFragment; import de.danoeh.antennapod.fragment.AllEpisodesFragment; import de.danoeh.antennapod.fragment.DownloadsFragment; @@ -266,12 +265,13 @@ public class NavListAdapter extends BaseAdapter holder.title.setText(feed.getTitle()); - int feedUnreadItems = DBReader.getNumberOfUnreadItems(context, feed.getId()); + if(feed.hasLastUpdateFailed()) { holder.failure.setVisibility(View.VISIBLE); } else { holder.failure.setVisibility(View.GONE); } + int feedUnreadItems = itemAccess.getNumberOfUnreadFeedItems(feed.getId()); if(feedUnreadItems > 0) { holder.count.setVisibility(View.VISIBLE); holder.count.setText(String.valueOf(feedUnreadItems)); @@ -301,6 +301,7 @@ public class NavListAdapter extends BaseAdapter int getSelectedItemIndex(); int getQueueSize(); int getNumberOfUnreadItems(); + int getNumberOfUnreadFeedItems(long feedId); } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java index 6787f28b5..91e3df106 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -43,9 +43,7 @@ import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.LongList; -import de.danoeh.antennapod.core.util.QueueAccess; import de.danoeh.antennapod.menuhandler.MenuItemUtils; -import de.danoeh.antennapod.menuhandler.NavDrawerActivity; /** * Shows unread or recently published episodes @@ -70,14 +68,13 @@ public class AllEpisodesFragment extends Fragment { private TextView txtvEmpty; private ProgressBar progLoading; - private List<FeedItem> unreadItems; - private List<FeedItem> recentItems; + private List<FeedItem> episodes; private LongList queueAccess; private List<Downloader> downloaderList; private boolean itemsLoaded = false; private boolean viewsCreated = false; - private boolean showOnlyNewEpisodes = false; + private final boolean showOnlyNewEpisodes; private AtomicReference<MainActivity> activity = new AtomicReference<MainActivity>(); @@ -225,7 +222,7 @@ public class AllEpisodesFragment extends Fragment { if (itemsLoaded) { MenuItem menuItem = menu.findItem(R.id.mark_all_read_item); if (menuItem != null) { - menuItem.setVisible(unreadItems != null && !unreadItems.isEmpty()); + menuItem.setVisible(episodes != null && !episodes.isEmpty()); } } } @@ -345,7 +342,7 @@ public class AllEpisodesFragment extends Fragment { @Override public int getCount() { if (itemsLoaded) { - return (showOnlyNewEpisodes) ? unreadItems.size() : recentItems.size(); + return episodes.size(); } return 0; } @@ -353,7 +350,7 @@ public class AllEpisodesFragment extends Fragment { @Override public FeedItem getItem(int position) { if (itemsLoaded) { - return (showOnlyNewEpisodes) ? unreadItems.get(position) : recentItems.get(position); + return episodes.get(position); } return null; } @@ -436,10 +433,17 @@ public class AllEpisodesFragment extends Fragment { protected Object[] doInBackground(Void... params) { Context context = activity.get(); if (context != null) { - return new Object[]{ - DBReader.getUnreadItemsList(context), - DBReader.getRecentlyPublishedEpisodes(context, RECENT_EPISODES_LIMIT), - DBReader.getQueueIDList(context)}; + if(showOnlyNewEpisodes) { + return new Object[] { + DBReader.getNewItemsList(context), + DBReader.getQueueIDList(context) + }; + } else { + return new Object[]{ + DBReader.getRecentlyPublishedEpisodes(context, RECENT_EPISODES_LIMIT), + DBReader.getQueueIDList(context) + }; + } } else { return null; } @@ -452,9 +456,8 @@ public class AllEpisodesFragment extends Fragment { progLoading.setVisibility(View.GONE); if (lists != null) { - unreadItems = (List<FeedItem>) lists[0]; - recentItems = (List<FeedItem>) lists[1]; - queueAccess = (LongList) lists[2]; + episodes = (List<FeedItem>) lists[0]; + queueAccess = (LongList) lists[1]; itemsLoaded = true; if (viewsCreated && activity.get() != null) { onFragmentLoaded(); |