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 foregroundColor = 0
|
||||||
var backgroundColor = 0
|
var backgroundColor = 0
|
||||||
var animateGifs = true
|
var animateGifs = true
|
||||||
|
var itemCnt = 0
|
||||||
|
|
||||||
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
||||||
getProperView(itemView).isSelected = select
|
getProperView(itemView).isSelected = select
|
||||||
|
@ -61,12 +62,17 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
else
|
else
|
||||||
itemView.dir_thumbnail
|
itemView.dir_thumbnail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateTitle(cnt: Int) {
|
||||||
|
actMode?.title = "$cnt / $itemCnt"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
foregroundColor = config.primaryColor
|
foregroundColor = config.primaryColor
|
||||||
backgroundColor = config.backgroundColor
|
backgroundColor = config.backgroundColor
|
||||||
animateGifs = config.animateGifs
|
animateGifs = config.animateGifs
|
||||||
|
itemCnt = dirs.size
|
||||||
}
|
}
|
||||||
|
|
||||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||||
|
@ -254,7 +260,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
multiSelector.setSelected(i, 0, true)
|
multiSelector.setSelected(i, 0, true)
|
||||||
notifyItemChanged(i)
|
notifyItemChanged(i)
|
||||||
}
|
}
|
||||||
actMode?.title = cnt.toString()
|
updateTitle(cnt)
|
||||||
actMode?.invalidate()
|
actMode?.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +349,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
if (!multiSelector.isSelectable) {
|
if (!multiSelector.isSelectable) {
|
||||||
activity.startSupportActionMode(multiSelectorCallback)
|
activity.startSupportActionMode(multiSelectorCallback)
|
||||||
multiSelector.setSelected(this, true)
|
multiSelector.setSelected(this, true)
|
||||||
actMode?.title = multiSelector.selectedPositions.size.toString()
|
updateTitle(multiSelector.selectedPositions.size)
|
||||||
toggleItemSelection(itemView, true, pos)
|
toggleItemSelection(itemView, true, pos)
|
||||||
actMode?.invalidate()
|
actMode?.invalidate()
|
||||||
}
|
}
|
||||||
|
@ -367,7 +373,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
if (selectedCnt == 0) {
|
if (selectedCnt == 0) {
|
||||||
actMode?.finish()
|
actMode?.finish()
|
||||||
} else {
|
} else {
|
||||||
actMode?.title = selectedCnt.toString()
|
updateTitle(selectedCnt)
|
||||||
}
|
}
|
||||||
actMode?.invalidate()
|
actMode?.invalidate()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -40,6 +40,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
var foregroundColor = 0
|
var foregroundColor = 0
|
||||||
var backgroundColor = 0
|
var backgroundColor = 0
|
||||||
var animateGifs = true
|
var animateGifs = true
|
||||||
|
var itemCnt = 0
|
||||||
|
|
||||||
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
||||||
getProperView(itemView).isSelected = select
|
getProperView(itemView).isSelected = select
|
||||||
|
@ -59,12 +60,17 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
else
|
else
|
||||||
itemView.medium_thumbnail
|
itemView.medium_thumbnail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateTitle(cnt: Int) {
|
||||||
|
actMode?.title = "$cnt / $itemCnt"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
foregroundColor = config.primaryColor
|
foregroundColor = config.primaryColor
|
||||||
backgroundColor = config.backgroundColor
|
backgroundColor = config.backgroundColor
|
||||||
animateGifs = config.animateGifs
|
animateGifs = config.animateGifs
|
||||||
|
itemCnt = media.size
|
||||||
}
|
}
|
||||||
|
|
||||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||||
|
@ -165,7 +171,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
multiSelector.setSelected(i, 0, true)
|
multiSelector.setSelected(i, 0, true)
|
||||||
notifyItemChanged(i)
|
notifyItemChanged(i)
|
||||||
}
|
}
|
||||||
actMode?.title = cnt.toString()
|
updateTitle(cnt)
|
||||||
actMode?.invalidate()
|
actMode?.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +270,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
if (!multiSelector.isSelectable) {
|
if (!multiSelector.isSelectable) {
|
||||||
activity.startSupportActionMode(multiSelectorCallback)
|
activity.startSupportActionMode(multiSelectorCallback)
|
||||||
multiSelector.setSelected(this, true)
|
multiSelector.setSelected(this, true)
|
||||||
actMode?.title = multiSelector.selectedPositions.size.toString()
|
updateTitle(multiSelector.selectedPositions.size)
|
||||||
toggleItemSelection(itemView, true, pos)
|
toggleItemSelection(itemView, true, pos)
|
||||||
actMode?.invalidate()
|
actMode?.invalidate()
|
||||||
}
|
}
|
||||||
|
@ -289,7 +295,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
if (selectedCnt == 0) {
|
if (selectedCnt == 0) {
|
||||||
actMode?.finish()
|
actMode?.finish()
|
||||||
} else {
|
} else {
|
||||||
actMode?.title = selectedCnt.toString()
|
updateTitle(selectedCnt)
|
||||||
}
|
}
|
||||||
actMode?.invalidate()
|
actMode?.invalidate()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue