mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-12-04 18:28:01 +01:00
add a helper function for getting the proper view in adapters
This commit is contained in:
parent
c2fb9ce0f3
commit
f7d774a439
2 changed files with 16 additions and 8 deletions
|
@ -42,10 +42,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
val markedItems = HashSet<Int>()
|
val markedItems = HashSet<Int>()
|
||||||
|
|
||||||
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
getProperView(itemView).isSelected = select
|
||||||
itemView.dir_frame.isSelected = select
|
|
||||||
else
|
|
||||||
itemView.dir_thumbnail.isSelected = select
|
|
||||||
|
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
return
|
return
|
||||||
|
@ -55,6 +52,13 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
else
|
else
|
||||||
markedItems.remove(pos)
|
markedItems.remove(pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getProperView(itemView: View): View {
|
||||||
|
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||||
|
itemView.dir_frame
|
||||||
|
else
|
||||||
|
itemView.dir_thumbnail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||||
|
|
|
@ -42,10 +42,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
val markedItems = HashSet<Int>()
|
val markedItems = HashSet<Int>()
|
||||||
|
|
||||||
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
getProperView(itemView).isSelected = select
|
||||||
itemView.medium_thumbnail_holder.isSelected = select
|
|
||||||
else
|
|
||||||
itemView.medium_thumbnail.isSelected = select
|
|
||||||
|
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
return
|
return
|
||||||
|
@ -55,6 +52,13 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
else
|
else
|
||||||
markedItems.remove(pos)
|
markedItems.remove(pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getProperView(itemView: View): View {
|
||||||
|
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||||
|
itemView.medium_thumbnail_holder
|
||||||
|
else
|
||||||
|
itemView.medium_thumbnail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||||
|
|
Loading…
Reference in a new issue