pull/2410/head
kunfei 2 years ago
parent 9ecc48b310
commit 83e62668eb
  1. 7
      app/src/main/java/io/legado/app/lib/prefs/ColorPreference.kt
  2. 2
      app/src/main/java/io/legado/app/lib/prefs/NameListPreference.kt
  3. 2
      app/src/main/java/io/legado/app/lib/prefs/Preference.kt
  4. 2
      app/src/main/java/io/legado/app/lib/prefs/SwitchPreference.kt

@ -10,7 +10,6 @@ import androidx.annotation.ColorInt
import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.FragmentActivity
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import com.jaredrummler.android.colorpicker.*
import io.legado.app.utils.ColorUtils
@ -118,14 +117,14 @@ class ColorPreference(context: Context, attrs: AttributeSet) : Preference(contex
}
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,
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) {
v.color = mColor
}
super.onBindViewHolder(holder)
}
override fun onSetInitialValue(defaultValue: Any?) {

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

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

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

Loading…
Cancel
Save