From f2306d295066874eb2cb467468a844f9d424f726 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Mon, 4 Mar 2019 02:11:17 +0100 Subject: [PATCH] Fixed download status update in NewEpisodesFragment --- .../fragment/AllEpisodesFragment.java | 18 ++++++++++++------ .../fragment/NewEpisodesFragment.java | 14 ++------------ 2 files changed, 14 insertions(+), 18 deletions(-) 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 ef522d3b3..beca6ab5c 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -414,20 +414,26 @@ public class AllEpisodesFragment extends Fragment { public void onEventMainThread(FeedItemEvent event) { Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]"); - if(episodes == null || listAdapter == null) { + if (episodes == null || listAdapter == null) { return; } - for(int i=0, size = event.items.size(); i < size; i++) { - FeedItem item = event.items.get(i); + for (FeedItem item : event.items) { int pos = FeedItemUtil.indexOfItemWithId(episodes, item.getId()); - if(pos >= 0) { + if (pos >= 0) { episodes.remove(pos); - episodes.add(pos, item); - listAdapter.notifyItemChanged(pos); + if (shouldUpdatedItemRemainInList(item)) { + episodes.add(pos, item); + listAdapter.notifyItemChanged(pos); + } else { + listAdapter.notifyItemRemoved(pos); + } } } } + protected boolean shouldUpdatedItemRemainInList(FeedItem item) { + return true; + } public void onEventMainThread(DownloadEvent event) { Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]"); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java index 6695ba427..335ee224b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java @@ -41,18 +41,8 @@ public class NewEpisodesFragment extends AllEpisodesFragment { } @Override - public void onEventMainThread(FeedItemEvent event) { - Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]"); - if(episodes == null) { - return; - } - for(FeedItem item : event.items) { - int pos = FeedItemUtil.indexOfItemWithId(episodes, item.getId()); - if(pos >= 0 && item.isTagged(FeedItem.TAG_QUEUE)) { - episodes.remove(pos); - listAdapter.notifyItemRemoved(pos); - } - } + protected boolean shouldUpdatedItemRemainInList(FeedItem item) { + return item.isNew(); } @Override