1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Update action mode title when necessary

This commit is contained in:
cketti 2012-09-13 06:41:04 +02:00
parent d9fad383eb
commit 997943a521

View File

@ -722,9 +722,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
mSelectedCount = getSelectionFromCheckboxes().size();
if (mSelectedCount > 0) {
mActionMode = MessageList.this.startActionMode(mActionModeCallback);
mActionMode.setTitle(String.format(
getString(R.string.actionbar_selected),
mSelectedCount));
updateActionModeTitle();
}
}
@ -2457,7 +2455,11 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
}
mAdapter.notifyDataSetChanged();
computeSelectAllVisibility();
if (isSelected) {
updateActionModeTitle();
computeSelectAllVisibility();
}
}
/**
@ -2477,7 +2479,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
if (newState) {
mSelectedCount = mAdapter.getCount();
mActionMode = MessageList.this.startActionMode(mActionModeCallback);
mActionMode.setTitle(String.format(getString(R.string.actionbar_selected), mSelectedCount));
updateActionModeTitle();
computeSelectAllVisibility();
} else {
mSelectedCount = 0;
@ -2493,6 +2495,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
}
}
mAdapter.notifyDataSetChanged();
updateActionModeTitle();
computeSelectAllVisibility();
}
@ -2514,7 +2517,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
mSelectedCount += 1;
}
mAdapter.notifyDataSetChanged();
mActionMode.setTitle(String.format(getString(R.string.actionbar_selected), mSelectedCount));
updateActionModeTitle();
// make sure the onPrepareActionMode is called
mActionMode.invalidate();
@ -2522,6 +2525,10 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
computeSelectAllVisibility();
}
private void updateActionModeTitle() {
mActionMode.setTitle(String.format(getString(R.string.actionbar_selected), mSelectedCount));
}
private void computeSelectAllVisibility() {
mActionModeCallback.showSelectAll(mSelectedCount != mAdapter.getCount());
}