diff options
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/adapter')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java | 2 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/SelectableAdapter.java | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java index 53223896f..8fb4a6314 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java @@ -48,6 +48,7 @@ public class EpisodeItemListAdapter extends SelectableAdapter<EpisodeItemViewHol public void updateItems(List<FeedItem> items) { episodes = items; notifyDataSetChanged(); + updateTitle(); } @Override @@ -195,6 +196,7 @@ public class EpisodeItemListAdapter extends SelectableAdapter<EpisodeItemViewHol return true; } else if (item.getItemId() == R.id.select_all_below) { setSelected(longPressedPosition + 1, getItemCount(), true); + shouldSelectLazyLoadedItems = true; return true; } return false; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SelectableAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SelectableAdapter.java index 43f749ff3..55669596b 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SelectableAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SelectableAdapter.java @@ -20,6 +20,7 @@ abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> extends Recy private final HashSet<Long> selectedIds = new HashSet<>(); private final Activity activity; private OnSelectModeListener onSelectModeListener; + boolean shouldSelectLazyLoadedItems = false; public SelectableAdapter(Activity activity) { this.activity = activity; @@ -34,6 +35,7 @@ abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> extends Recy onSelectModeListener.onStartSelectMode(); } + shouldSelectLazyLoadedItems = false; selectedIds.clear(); selectedIds.add(getItemId(pos)); notifyDataSetChanged(); @@ -56,9 +58,10 @@ abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> extends Recy @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { if (item.getItemId() == R.id.select_toggle) { - boolean allSelected = selectedIds.size() == getItemCount(); - setSelected(0, getItemCount(), !allSelected); - toggleSelectAllIcon(item, !allSelected); + boolean selectAll = selectedIds.size() != getItemCount(); + shouldSelectLazyLoadedItems = selectAll; + setSelected(0, getItemCount(), selectAll); + toggleSelectAllIcon(item, selectAll); updateTitle(); return true; } @@ -69,6 +72,7 @@ abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> extends Recy public void onDestroyActionMode(ActionMode mode) { callOnEndSelectMode(); actionMode = null; + shouldSelectLazyLoadedItems = false; selectedIds.clear(); notifyDataSetChanged(); } @@ -147,7 +151,7 @@ abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> extends Recy } } - private void updateTitle() { + void updateTitle() { if (actionMode == null) { return; } @@ -166,6 +170,10 @@ abstract class SelectableAdapter<T extends RecyclerView.ViewHolder> extends Recy } } + public boolean shouldSelectLazyLoadedItems() { + return shouldSelectLazyLoadedItems; + } + public interface OnSelectModeListener { void onStartSelectMode(); |