show the total file count at long press selection too

This commit is contained in:
tibbi 2017-03-18 20:27:54 +01:00
parent 348a19657e
commit 3e7fec4f72
1 changed files with 9 additions and 2 deletions

View File

@ -37,6 +37,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
var actMode: ActionMode? = null var actMode: ActionMode? = null
val markedItems = HashSet<Int>() val markedItems = HashSet<Int>()
var textColor = 0 var textColor = 0
var itemCnt = 0
lateinit var folderDrawable: Drawable lateinit var folderDrawable: Drawable
lateinit var fileDrawable: Drawable lateinit var fileDrawable: Drawable
@ -51,6 +52,10 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
else else
markedItems.remove(pos) markedItems.remove(pos)
} }
fun updateTitle(cnt: Int) {
actMode?.title = "$cnt / $itemCnt"
}
} }
init { init {
@ -59,6 +64,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
folderDrawable.alpha = 180 folderDrawable.alpha = 180
fileDrawable = activity.resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_file, textColor) fileDrawable = activity.resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_file, textColor)
fileDrawable.alpha = 180 fileDrawable.alpha = 180
itemCnt = mItems.size
} }
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
@ -179,6 +185,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
mItems.removeAll(removeFiles) mItems.removeAll(removeFiles)
markedItems.clear() markedItems.clear()
listener?.deleteFiles(files) listener?.deleteFiles(files)
itemCnt = mItems.size
} }
} }
@ -233,7 +240,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
if (!multiSelector.isSelectable) { if (!multiSelector.isSelectable) {
activity.startSupportActionMode(multiSelectorCallback) activity.startSupportActionMode(multiSelectorCallback)
multiSelector.setSelected(this@ViewHolder, true) multiSelector.setSelected(this@ViewHolder, true)
actMode?.title = multiSelector.selectedPositions.size.toString() updateTitle(multiSelector.selectedPositions.size)
toggleItemSelection(this, true, pos) toggleItemSelection(this, true, pos)
actMode?.invalidate() actMode?.invalidate()
} }
@ -259,7 +266,7 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
if (selectedCnt == 0) { if (selectedCnt == 0) {
actMode?.finish() actMode?.finish()
} else { } else {
actMode?.title = selectedCnt.toString() updateTitle(selectedCnt)
} }
actMode?.invalidate() actMode?.invalidate()
} else { } else {