From ce5dc20a79d4a33550d7d8c406e068a0b55d6efa Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 4 Mar 2017 23:11:56 +0100 Subject: [PATCH] fix #172, show selected items count as "x / y" --- .../gallery/adapters/DirectoryAdapter.kt | 12 +++++++++--- .../gallery/adapters/MediaAdapter.kt | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 5bfa156b7..dd2e72917 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -42,6 +42,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList, var foregroundColor = 0 var backgroundColor = 0 var animateGifs = true + var itemCnt = 0 fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) { getProperView(itemView).isSelected = select @@ -59,12 +60,17 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, else itemView.medium_thumbnail } + + fun updateTitle(cnt: Int) { + actMode?.title = "$cnt / $itemCnt" + } } init { foregroundColor = config.primaryColor backgroundColor = config.backgroundColor animateGifs = config.animateGifs + itemCnt = media.size } val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { @@ -165,7 +171,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, multiSelector.setSelected(i, 0, true) notifyItemChanged(i) } - actMode?.title = cnt.toString() + updateTitle(cnt) actMode?.invalidate() } @@ -264,7 +270,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, if (!multiSelector.isSelectable) { activity.startSupportActionMode(multiSelectorCallback) multiSelector.setSelected(this, true) - actMode?.title = multiSelector.selectedPositions.size.toString() + updateTitle(multiSelector.selectedPositions.size) toggleItemSelection(itemView, true, pos) actMode?.invalidate() } @@ -289,7 +295,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, if (selectedCnt == 0) { actMode?.finish() } else { - actMode?.title = selectedCnt.toString() + updateTitle(selectedCnt) } actMode?.invalidate() } else {