pull/1463/head^2
gedoor 3 years ago
parent 75ddba2730
commit e0d146b8ba
  1. 3
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  2. 6
      app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt
  3. 6
      app/src/main/java/io/legado/app/ui/widget/prefs/SwitchPreference.kt

@ -67,6 +67,9 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
putPrefBoolean(PreferKey.webService, WebService.isRun) putPrefBoolean(PreferKey.webService, WebService.isRun)
addPreferencesFromResource(R.xml.pref_main) addPreferencesFromResource(R.xml.pref_main)
findPreference<SwitchPreference>("webService")?.onLongClick { findPreference<SwitchPreference>("webService")?.onLongClick {
if (!WebService.isRun) {
return@onLongClick false
}
context?.selector(arrayListOf("复制地址", "浏览器打开")) { _, i -> context?.selector(arrayListOf("复制地址", "浏览器打开")) { _, i ->
when (i) { when (i) {
0 -> context?.sendToClip(it.summary.toString()) 0 -> context?.sendToClip(it.summary.toString())

@ -116,8 +116,10 @@ class Preference(context: Context, attrs: AttributeSet) :
isBottomBackground = isBottomBackground isBottomBackground = isBottomBackground
) )
super.onBindViewHolder(holder) super.onBindViewHolder(holder)
holder.itemView.onLongClick { onLongClick?.let { listener ->
onLongClick?.invoke(this) holder.itemView.onLongClick {
listener.invoke(this)
}
} }
} }

@ -37,8 +37,10 @@ class SwitchPreference(context: Context, attrs: AttributeSet) :
v.applyTint(context.accentColor) v.applyTint(context.accentColor)
} }
super.onBindViewHolder(holder) super.onBindViewHolder(holder)
holder.itemView.setOnLongClickListener { onLongClick?.let { listener ->
onLongClick?.invoke(this) ?: false holder.itemView.setOnLongClickListener {
listener.invoke(this)
}
} }
} }

Loading…
Cancel
Save