mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -31,7 +31,9 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
|
|||||||
TextToSpeech.OnInitListener {
|
TextToSpeech.OnInitListener {
|
||||||
|
|
||||||
private val binding = PopupActionMenuBinding.inflate(LayoutInflater.from(context))
|
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 menuItems: List<MenuItemImpl>
|
||||||
private val visibleMenuItems = arrayListOf<MenuItemImpl>()
|
private val visibleMenuItems = arrayListOf<MenuItemImpl>()
|
||||||
private val moreMenuItems = 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) :
|
inner class Adapter(context: Context) :
|
||||||
RecyclerAdapter<MenuItemImpl, ItemTextBinding>(context) {
|
RecyclerAdapter<MenuItemImpl, ItemTextBinding>(context) {
|
||||||
|
|
||||||
|
override fun getItemId(position: Int): Long {
|
||||||
|
return position.toLong()
|
||||||
|
}
|
||||||
|
|
||||||
override fun getViewBinding(parent: ViewGroup): ItemTextBinding {
|
override fun getViewBinding(parent: ViewGroup): ItemTextBinding {
|
||||||
return ItemTextBinding.inflate(inflater, parent, false)
|
return ItemTextBinding.inflate(inflater, parent, false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ class PopupAction(private val context: Context) :
|
|||||||
|
|
||||||
val binding = PopupActionBinding.inflate(context.layoutInflater)
|
val binding = PopupActionBinding.inflate(context.layoutInflater)
|
||||||
val adapter by lazy {
|
val adapter by lazy {
|
||||||
Adapter(context)
|
Adapter(context).apply {
|
||||||
|
setHasStableIds(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var onActionClick: ((action: String) -> Unit)? = null
|
var onActionClick: ((action: String) -> Unit)? = null
|
||||||
|
|
||||||
@@ -36,6 +38,10 @@ class PopupAction(private val context: Context) :
|
|||||||
inner class Adapter(context: Context) :
|
inner class Adapter(context: Context) :
|
||||||
RecyclerAdapter<SelectItem<String>, ItemTextBinding>(context) {
|
RecyclerAdapter<SelectItem<String>, ItemTextBinding>(context) {
|
||||||
|
|
||||||
|
override fun getItemId(position: Int): Long {
|
||||||
|
return position.toLong()
|
||||||
|
}
|
||||||
|
|
||||||
override fun getViewBinding(parent: ViewGroup): ItemTextBinding {
|
override fun getViewBinding(parent: ViewGroup): ItemTextBinding {
|
||||||
return ItemTextBinding.inflate(inflater, parent, false)
|
return ItemTextBinding.inflate(inflater, parent, false)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user