Add select inverse action

This commit is contained in:
arkon
2020-04-05 15:55:35 -04:00
parent 9c44cae5b8
commit 985bb44559
7 changed files with 72 additions and 1 deletions
@@ -338,6 +338,7 @@ class UpdatesController : NucleusController<UpdatesPresenter>(),
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_select_all -> selectAll()
R.id.action_select_inverse -> selectInverse()
R.id.action_download -> downloadChapters(getSelectedChapters())
R.id.action_delete -> ConfirmDeleteChaptersDialog(this, getSelectedChapters())
.showDialog(router)
@@ -364,4 +365,13 @@ class UpdatesController : NucleusController<UpdatesPresenter>(),
adapter.selectAll()
actionMode?.invalidate()
}
private fun selectInverse() {
val adapter = adapter ?: return
for (i in 0..adapter.itemCount) {
adapter.toggleSelection(i)
}
actionMode?.invalidate()
adapter.notifyDataSetChanged()
}
}