add easier toggling between clickable recyclerview items
This commit is contained in:
parent
2ce3c20ba7
commit
850662daaf
3 changed files with 4 additions and 4 deletions
|
@ -7,7 +7,7 @@ buildscript {
|
|||
propMinSdkVersion = 16
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '4.2.10'
|
||||
propVersionName = '4.2.11'
|
||||
kotlin_version = '1.2.50'
|
||||
support_libs = '27.1.1'
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class FilepickerItemsAdapter(activity: BaseSimpleActivity, val fileDirItems: Lis
|
|||
|
||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||
val fileDirItem = fileDirItems[position]
|
||||
val view = holder.bindView(fileDirItem, false) { itemView, adapterPosition ->
|
||||
val view = holder.bindView(fileDirItem, true, false) { itemView, adapterPosition ->
|
||||
setupView(itemView, fileDirItem)
|
||||
}
|
||||
bindViewHolder(holder, position, view)
|
||||
|
|
|
@ -300,11 +300,11 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc
|
|||
open class ViewHolder(view: View, val adapterListener: MyAdapterListener? = null, val activity: BaseSimpleActivity? = null,
|
||||
val multiSelectorCallback: ModalMultiSelectorCallback? = null, val multiSelector: MultiSelector,
|
||||
val positionOffset: Int = 0, val itemClick: ((Any) -> (Unit))? = null) : SwappingHolder(view, multiSelector) {
|
||||
fun bindView(any: Any, allowLongClick: Boolean = true, callback: (itemView: View, adapterPosition: Int) -> Unit): View {
|
||||
fun bindView(any: Any, allowSingleClick: Boolean = true, allowLongClick: Boolean = true, callback: (itemView: View, adapterPosition: Int) -> Unit): View {
|
||||
return itemView.apply {
|
||||
callback(this, adapterPosition)
|
||||
|
||||
if (isClickable) {
|
||||
if (allowSingleClick) {
|
||||
setOnClickListener { viewClicked(any) }
|
||||
setOnLongClickListener { if (allowLongClick) viewLongClicked() else viewClicked(any); true }
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue