diff --git a/app/src/main/java/io/legado/app/lib/prefs/ColorPreference.kt b/app/src/main/java/io/legado/app/lib/prefs/ColorPreference.kt index 3eb688d78..f54775d6d 100644 --- a/app/src/main/java/io/legado/app/lib/prefs/ColorPreference.kt +++ b/app/src/main/java/io/legado/app/lib/prefs/ColorPreference.kt @@ -116,8 +116,7 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex } } - override fun onBindViewHolder(holder: PreferenceViewHolder) { - super.onBindViewHolder(holder) + override fun onBindView(holder: PreferenceViewHolder) { val v = bindView( context, holder, icon, title, summary, widgetLayoutResource, R.id.cpv_preference_preview_color_panel, 30, 30 diff --git a/app/src/main/java/io/legado/app/lib/prefs/Preference.kt b/app/src/main/java/io/legado/app/lib/prefs/Preference.kt index f2cbb2fb4..784c2972b 100644 --- a/app/src/main/java/io/legado/app/lib/prefs/Preference.kt +++ b/app/src/main/java/io/legado/app/lib/prefs/Preference.kt @@ -108,16 +108,9 @@ open class Preference(context: Context, attrs: AttributeSet) : } - override fun onBindViewHolder(holder: PreferenceViewHolder) { - bindView( - context, - holder, - icon, - title, - summary, - isBottomBackground = isBottomBackground - ) + final override fun onBindViewHolder(holder: PreferenceViewHolder) { super.onBindViewHolder(holder) + onBindView(holder) onLongClick?.let { listener -> holder.itemView.onLongClick { listener.invoke(this) @@ -125,6 +118,13 @@ open class Preference(context: Context, attrs: AttributeSet) : } } + open fun onBindView(holder: PreferenceViewHolder) { + bindView( + context, holder, icon, title, summary, + isBottomBackground = isBottomBackground + ) + } + fun onLongClick(listener: (preference: Preference) -> Boolean) { onLongClick = listener }