add a helper function for getting the proper view in adapters

This commit is contained in:
tibbi 2016-12-25 21:20:55 +01:00
parent c2fb9ce0f3
commit f7d774a439
2 changed files with 16 additions and 8 deletions

View file

@ -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) {

View file

@ -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) {