mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Update selection in FileListListAdapter using ID received from list instead of position, so that changes removals or additions in the list result in correct update of the drawn selection
This commit is contained in:
parent
db6acc6868
commit
0a4ac6e91c
2 changed files with 7 additions and 13 deletions
|
@ -476,17 +476,12 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
|
|||
return mSelection.contains(getItemId(position));
|
||||
}
|
||||
|
||||
public void updateSelection(int position, boolean checked) {
|
||||
public void updateSelection(long itemId, boolean checked) {
|
||||
if (checked) {
|
||||
mSelection.add(getItemId(position));
|
||||
notifyDataSetChanged();
|
||||
mSelection.add(itemId);
|
||||
} else {
|
||||
removeSelection(position);
|
||||
mSelection.remove(itemId);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSelection(int position) {
|
||||
mSelection.remove(getItemId(position));
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ public class OCFileListFragment extends ExtendedListFragment {
|
|||
|
||||
@Override
|
||||
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
|
||||
mAdapter.updateSelection(position, checked);
|
||||
mAdapter.updateSelection(id, checked);
|
||||
mode.invalidate();
|
||||
}
|
||||
|
||||
|
@ -376,18 +376,17 @@ public class OCFileListFragment extends ExtendedListFragment {
|
|||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
final int checkedCount = getListView().getCheckedItemCount();
|
||||
List<OCFile> checkedFiles = mAdapter.getCheckedItems();
|
||||
final int checkedCount = checkedFiles.size();
|
||||
String title = getResources().getQuantityString(
|
||||
R.plurals.items_selected_count,
|
||||
checkedCount,
|
||||
checkedCount
|
||||
);
|
||||
mode.setTitle(title);
|
||||
|
||||
if (checkedCount > 0) {
|
||||
List<OCFile> targetFiles = mAdapter.getCheckedItems();
|
||||
FileMenuFilter mf = new FileMenuFilter(
|
||||
targetFiles,
|
||||
checkedFiles,
|
||||
((FileActivity) getActivity()).getAccount(),
|
||||
mContainerActivity,
|
||||
getActivity()
|
||||
|
|
Loading…
Reference in a new issue