Fixed download status update in NewEpisodesFragment

This commit is contained in:
ByteHamster 2019-03-04 02:11:17 +01:00
parent 1593a06077
commit f2306d2950
2 changed files with 14 additions and 18 deletions

View File

@ -417,17 +417,23 @@ public class AllEpisodesFragment extends Fragment {
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) {
episodes.remove(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 + "]");

View File

@ -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