mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user