Merge pull request #3048 from ByteHamster/new-episodes-download

Fixed download status update in NewEpisodesFragment
This commit is contained in:
H. Lehmann 2019-03-08 12:15:23 +01:00 committed by GitHub
commit 6212455431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 18 deletions

View File

@ -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 + "]");

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