1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-02 00:25:10 -04:00

Made the selectAll working again. This also got rid of the 2 settings options in the actionbar.

This commit is contained in:
Sander Bogaert 2012-07-25 16:20:01 -04:00 committed by Andrew Chen
parent c7003ab028
commit 4a7a61bd08

View File

@ -1499,6 +1499,8 @@ public class MessageList extends K9ListActivity implements
return true;
}
case R.id.select_all:
toggleAllSelected();
return true;
case R.id.app_settings: {
onEditPrefs();
return true;
@ -2363,6 +2365,32 @@ public class MessageList extends K9ListActivity implements
mAdapter.notifyDataSetChanged();
}
private void toggleAllSelected() {
boolean newState = true;
synchronized (mAdapter.messages) {
if (mSelectedCount > 0) {
newState = false;
}
mSelectedCount = 0;
for (MessageInfoHolder holder : mAdapter.messages) {
holder.selected = newState;
mSelectedCount += (newState ? 1 : 0);
}
if (newState) {
mActionMode = MessageList.this.startActionMode(mActionModeCallback);
mActionMode.setTitle(String.format(getString(R.string.actionbar_selected), mSelectedCount));
} else {
mActionMode.finish();
mSelectedCount = 0;
}
}
mAdapter.notifyDataSetChanged();
}
private void setSelected(final List<MessageInfoHolder> holders, final boolean newState) {
for (final MessageInfoHolder holder : holders) {
if (holder.selected != newState) {