mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-12-03 17:57:59 +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>()
|
||||
|
||||
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
itemView.dir_frame.isSelected = select
|
||||
else
|
||||
itemView.dir_thumbnail.isSelected = select
|
||||
getProperView(itemView).isSelected = select
|
||||
|
||||
if (pos == -1)
|
||||
return
|
||||
|
@ -55,6 +52,13 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
else
|
||||
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) {
|
||||
|
|
|
@ -42,10 +42,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
val markedItems = HashSet<Int>()
|
||||
|
||||
fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
itemView.medium_thumbnail_holder.isSelected = select
|
||||
else
|
||||
itemView.medium_thumbnail.isSelected = select
|
||||
getProperView(itemView).isSelected = select
|
||||
|
||||
if (pos == -1)
|
||||
return
|
||||
|
@ -55,6 +52,13 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
else
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue