kunfei пре 4 година
родитељ
комит
eb2086ccc4

+ 3 - 4
app/src/main/java/io/legado/app/lib/prefs/ColorPreference.kt

@@ -10,7 +10,6 @@ import androidx.annotation.ColorInt
 import androidx.annotation.StringRes
 import androidx.annotation.StringRes
 import androidx.appcompat.app.AlertDialog
 import androidx.appcompat.app.AlertDialog
 import androidx.fragment.app.FragmentActivity
 import androidx.fragment.app.FragmentActivity
-import androidx.preference.Preference
 import androidx.preference.PreferenceViewHolder
 import androidx.preference.PreferenceViewHolder
 import com.jaredrummler.android.colorpicker.*
 import com.jaredrummler.android.colorpicker.*
 import io.legado.app.utils.ColorUtils
 import io.legado.app.utils.ColorUtils
@@ -118,14 +117,14 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex
     }
     }
 
 
     override fun onBindViewHolder(holder: PreferenceViewHolder) {
     override fun onBindViewHolder(holder: PreferenceViewHolder) {
-        val v = io.legado.app.lib.prefs.Preference.bindView<ColorPanelView>(
+        super.onBindViewHolder(holder)
+        val v = bindView<ColorPanelView>(
             context, holder, icon, title, summary, widgetLayoutResource,
             context, holder, icon, title, summary, widgetLayoutResource,
-            com.jaredrummler.android.colorpicker.R.id.cpv_preference_preview_color_panel, 30, 30
+            R.id.cpv_preference_preview_color_panel, 30, 30
         )
         )
         if (v is ColorPanelView) {
         if (v is ColorPanelView) {
             v.color = mColor
             v.color = mColor
         }
         }
-        super.onBindViewHolder(holder)
     }
     }
 
 
     override fun onSetInitialValue(defaultValue: Any?) {
     override fun onSetInitialValue(defaultValue: Any?) {

+ 1 - 1
app/src/main/java/io/legado/app/lib/prefs/NameListPreference.kt

@@ -24,6 +24,7 @@ class NameListPreference(context: Context, attrs: AttributeSet) : ListPreference
     }
     }
 
 
     override fun onBindViewHolder(holder: PreferenceViewHolder) {
     override fun onBindViewHolder(holder: PreferenceViewHolder) {
+        super.onBindViewHolder(holder)
         val v = Preference.bindView<TextView>(
         val v = Preference.bindView<TextView>(
             context, holder, icon, title, summary, widgetLayoutResource,
             context, holder, icon, title, summary, widgetLayoutResource,
             R.id.text_view, isBottomBackground = isBottomBackground
             R.id.text_view, isBottomBackground = isBottomBackground
@@ -36,7 +37,6 @@ class NameListPreference(context: Context, attrs: AttributeSet) : ListPreference
                 v.setTextColor(pTextColor)
                 v.setTextColor(pTextColor)
             }
             }
         }
         }
-        super.onBindViewHolder(holder)
     }
     }
 
 
 }
 }

+ 1 - 1
app/src/main/java/io/legado/app/lib/prefs/Preference.kt

@@ -20,7 +20,7 @@ import io.legado.app.utils.ColorUtils
 import splitties.views.onLongClick
 import splitties.views.onLongClick
 import kotlin.math.roundToInt
 import kotlin.math.roundToInt
 
 
-class Preference(context: Context, attrs: AttributeSet) :
+open class Preference(context: Context, attrs: AttributeSet) :
     androidx.preference.Preference(context, attrs) {
     androidx.preference.Preference(context, attrs) {
 
 
     private var onLongClick: ((preference: Preference) -> Boolean)? = null
     private var onLongClick: ((preference: Preference) -> Boolean)? = null

+ 1 - 1
app/src/main/java/io/legado/app/lib/prefs/SwitchPreference.kt

@@ -23,6 +23,7 @@ class SwitchPreference(context: Context, attrs: AttributeSet) :
     }
     }
 
 
     override fun onBindViewHolder(holder: PreferenceViewHolder) {
     override fun onBindViewHolder(holder: PreferenceViewHolder) {
+        super.onBindViewHolder(holder)
         val v = Preference.bindView<SwitchCompat>(
         val v = Preference.bindView<SwitchCompat>(
             context,
             context,
             holder,
             holder,
@@ -36,7 +37,6 @@ class SwitchPreference(context: Context, attrs: AttributeSet) :
         if (v is SwitchCompat && !v.isInEditMode) {
         if (v is SwitchCompat && !v.isInEditMode) {
             v.applyTint(context.accentColor)
             v.applyTint(context.accentColor)
         }
         }
-        super.onBindViewHolder(holder)
         onLongClick?.let { listener ->
         onLongClick?.let { listener ->
             holder.itemView.setOnLongClickListener {
             holder.itemView.setOnLongClickListener {
                 listener.invoke(this)
                 listener.invoke(this)