Fix select all menu item behaviour and add icon

This commit is contained in:
Shinokuni 2019-05-18 16:32:56 +02:00
parent 432726defa
commit 3a163c1de5
4 changed files with 20 additions and 3 deletions

View File

@ -265,8 +265,14 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
setReadState(false); setReadState(false);
break; break;
case R.id.item_select_all: case R.id.item_select_all:
adapter.selectAll(); if (allItemsSelected) {
allItemsSelected = true; adapter.unselectAll();
allItemsSelected = false;
actionMode.finish();
} else {
adapter.selectAll();
allItemsSelected = true;
}
break; break;
} }

View File

@ -205,6 +205,11 @@ public class MainItemListAdapter extends PagedListAdapter<ItemWithFeed, MainItem
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void unselectAll() {
selection.clear();
notifyDataSetChanged();
}
public List<ItemWithFeed> getSelectedItems() { public List<ItemWithFeed> getSelectedItems() {
List<ItemWithFeed> items = new ArrayList<>(); List<ItemWithFeed> items = new ArrayList<>();

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M3,5h2L5,3c-1.1,0 -2,0.9 -2,2zM3,13h2v-2L3,11v2zM7,21h2v-2L7,19v2zM3,9h2L5,7L3,7v2zM13,3h-2v2h2L13,3zM19,3v2h2c0,-1.1 -0.9,-2 -2,-2zM5,21v-2L3,19c0,1.1 0.9,2 2,2zM3,17h2v-2L3,15v2zM9,3L7,3v2h2L9,3zM11,21h2v-2h-2v2zM19,13h2v-2h-2v2zM19,21c1.1,0 2,-0.9 2,-2h-2v2zM19,9h2L21,7h-2v2zM19,17h2v-2h-2v2zM15,21h2v-2h-2v2zM15,5h2L17,3h-2v2zM7,17h10L17,7L7,7v10zM9,9h6v6L9,15L9,9z"/>
</vector>

View File

@ -17,6 +17,7 @@
<item <item
android:id="@+id/item_select_all" android:id="@+id/item_select_all"
android:title="@string/select_all" android:title="@string/select_all"
app:showAsAction="never" /> android:icon="@drawable/ic_select_all_white"
app:showAsAction="ifRoom" />
</menu> </menu>