This commit is contained in:
821938089
2022-07-23 06:41:27 +08:00
parent e2ec305839
commit 1b94de3956
2 changed files with 14 additions and 2 deletions

View File

@@ -31,7 +31,9 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
TextToSpeech.OnInitListener {
private val binding = PopupActionMenuBinding.inflate(LayoutInflater.from(context))
private val adapter = Adapter(context)
private val adapter = Adapter(context).apply {
setHasStableIds(true)
}
private val menuItems: List<MenuItemImpl>
private val visibleMenuItems = arrayListOf<MenuItemImpl>()
private val moreMenuItems = arrayListOf<MenuItemImpl>()
@@ -157,6 +159,10 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
inner class Adapter(context: Context) :
RecyclerAdapter<MenuItemImpl, ItemTextBinding>(context) {
override fun getItemId(position: Int): Long {
return position.toLong()
}
override fun getViewBinding(parent: ViewGroup): ItemTextBinding {
return ItemTextBinding.inflate(inflater, parent, false)
}

View File

@@ -15,7 +15,9 @@ class PopupAction(private val context: Context) :
val binding = PopupActionBinding.inflate(context.layoutInflater)
val adapter by lazy {
Adapter(context)
Adapter(context).apply {
setHasStableIds(true)
}
}
var onActionClick: ((action: String) -> Unit)? = null
@@ -36,6 +38,10 @@ class PopupAction(private val context: Context) :
inner class Adapter(context: Context) :
RecyclerAdapter<SelectItem<String>, ItemTextBinding>(context) {
override fun getItemId(position: Int): Long {
return position.toLong()
}
override fun getViewBinding(parent: ViewGroup): ItemTextBinding {
return ItemTextBinding.inflate(inflater, parent, false)
}