Skip to content

Commit

Permalink
Fix counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Keidan committed Jun 18, 2021
1 parent 324094f commit 6e036bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public SearchableListArrayAdapter(final Context context, DisplayCharPolicy polic

/**
* Toggles the item selection.
*
* @param position Item position.
*/
public void toggleSelection(int position) {
Expand All @@ -83,8 +84,9 @@ public void removeSelection() {

/**
* Select a view.
*
* @param position Position.
* @param value Selection value.
* @param value Selection value.
*/
private void selectView(int position, boolean value) {
if (value)
Expand All @@ -94,8 +96,18 @@ private void selectView(int position, boolean value) {
notifyDataSetChanged();
}

/**
* Returns the selection count.
*
* @return int
*/
public int getSelectedCount() {
return mSelectedItemsIds.size();
}

/**
* Returns the selected ids.
*
* @return SparseBooleanArray
*/
public SparseBooleanArray getSelectedIds() {
Expand All @@ -104,6 +116,7 @@ public SparseBooleanArray getSelectedIds() {

/**
* Returns if the position is checked or not.
*
* @param position The item position.
* @return boolean
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
*/
private void showUndoSnackbar() {
final Context c = mSnackBarLayout.getContext();
final int checkedCount = mListView.getCheckedItemCount();
final int checkedCount = mAdapter.getSelectedCount();
mCustomSnackBar = Snackbar.make(mSnackBarLayout, String.format(c.getString(R.string.items_deleted), checkedCount), Snackbar.LENGTH_LONG);
mCustomSnackBar.setAction(c.getString(R.string.cancel), (v) -> mAdapter.undoDelete());
mCustomSnackBar.addCallback(new Snackbar.Callback() {
Expand Down

0 comments on commit 6e036bd

Please sign in to comment.