Skip to content

Commit

Permalink
#287: Fix selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Keidan committed Nov 19, 2023
1 parent 3121bbd commit d345690
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public abstract class GenericMultiChoiceCallback implements AbsListView.MultiCho
private final ClipboardManager mClipboard;
private int mFirstSelection = -1;
private final AlertDialog mProgress;
private MenuItem mMenuItemSelectAll;

@SuppressLint("InflateParams")
protected GenericMultiChoiceCallback(MainActivity mainActivity, final ListView listView, final SearchableListArrayAdapter adapter) {
Expand Down Expand Up @@ -69,6 +70,7 @@ protected GenericMultiChoiceCallback(MainActivity mainActivity, final ListView l
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mode.getMenuInflater().inflate(getMenuId(), menu);
mMenuItemSelectAll = menu.findItem(R.id.action_select_all);
return true;
}

Expand Down Expand Up @@ -139,6 +141,9 @@ public void onItemCheckedStateChanged(ActionMode mode, int position, long id, bo
mAdapter.toggleSelection(position, checked);
if (checkedCount == 1)
mFirstSelection = mAdapter.getSelectedIds().get(0);
if (mMenuItemSelectAll != null)
mMenuItemSelectAll.setChecked(!mMenuItemSelectAll.isChecked() &&
mAdapter.getSelectedCount() == mAdapter.getCount());
}

/**
Expand Down

0 comments on commit d345690

Please sign in to comment.