adding extra actionmode related callbacks to recyclerview adapter
This commit is contained in:
parent
f75d80ee20
commit
40b180e576
4 changed files with 15 additions and 1 deletions
|
@ -7,7 +7,7 @@ buildscript {
|
|||
propMinSdkVersion = 21
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '5.20.8'
|
||||
propVersionName = '5.20.9'
|
||||
kotlin_version = '1.3.61'
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,10 @@ class FilepickerItemsAdapter(activity: BaseSimpleActivity, val fileDirItems: Lis
|
|||
|
||||
override fun getItemSelectionKey(position: Int) = fileDirItems[position].path.hashCode()
|
||||
|
||||
override fun onActionModeCreated() {}
|
||||
|
||||
override fun onActionModeDestroyed() {}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||
|
|
|
@ -47,6 +47,10 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc
|
|||
|
||||
abstract fun getItemKeyPosition(key: Int): Int
|
||||
|
||||
abstract fun onActionModeCreated()
|
||||
|
||||
abstract fun onActionModeDestroyed()
|
||||
|
||||
protected fun isOneItemSelected() = selectedKeys.size == 1
|
||||
|
||||
init {
|
||||
|
@ -72,6 +76,7 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc
|
|||
}
|
||||
}
|
||||
activity.menuInflater.inflate(getActionMenuId(), menu)
|
||||
onActionModeCreated()
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -93,6 +98,7 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc
|
|||
actBarTextView?.text = ""
|
||||
actMode = null
|
||||
lastLongPressedItem = -1
|
||||
onActionModeDestroyed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,10 @@ class StringsAdapter(activity: BaseSimpleActivity, var strings: MutableList<Stri
|
|||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.list_item, parent)
|
||||
|
||||
override fun onActionModeCreated() {}
|
||||
|
||||
override fun onActionModeDestroyed() {}
|
||||
|
||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||
val item = strings[position]
|
||||
holder.bindView(item, true, true) { itemView, layoutPosition ->
|
||||
|
|
Loading…
Reference in a new issue