mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 13:08:00 +01:00
fix #172, show selected items count as "x / y"
This commit is contained in:
parent
c494209523
commit
ce5dc20a79
2 changed files with 18 additions and 6 deletions
|
@ -42,6 +42,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
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
|
||||
|
@ -61,12 +62,17 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
else
|
||||
itemView.dir_thumbnail
|
||||
}
|
||||
|
||||
fun updateTitle(cnt: Int) {
|
||||
actMode?.title = "$cnt / $itemCnt"
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
foregroundColor = config.primaryColor
|
||||
backgroundColor = config.backgroundColor
|
||||
animateGifs = config.animateGifs
|
||||
itemCnt = dirs.size
|
||||
}
|
||||
|
||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||
|
@ -254,7 +260,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
multiSelector.setSelected(i, 0, true)
|
||||
notifyItemChanged(i)
|
||||
}
|
||||
actMode?.title = cnt.toString()
|
||||
updateTitle(cnt)
|
||||
actMode?.invalidate()
|
||||
}
|
||||
|
||||
|
@ -343,7 +349,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
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()
|
||||
}
|
||||
|
@ -367,7 +373,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
if (selectedCnt == 0) {
|
||||
actMode?.finish()
|
||||
} else {
|
||||
actMode?.title = selectedCnt.toString()
|
||||
updateTitle(selectedCnt)
|
||||
}
|
||||
actMode?.invalidate()
|
||||
} else {
|
||||
|
|
|
@ -40,6 +40,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
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<Medium>,
|
|||
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<Medium>,
|
|||
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<Medium>,
|
|||
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<Medium>,
|
|||
if (selectedCnt == 0) {
|
||||
actMode?.finish()
|
||||
} else {
|
||||
actMode?.title = selectedCnt.toString()
|
||||
updateTitle(selectedCnt)
|
||||
}
|
||||
actMode?.invalidate()
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue