pull/1463/head^2
gedoor 3 years ago
parent 1bc1abb797
commit 4e63e66788
  1. 2
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  2. 8
      app/src/main/java/io/legado/app/ui/widget/prefs/Preference.kt

@ -123,7 +123,7 @@ class BackupConfigFragment : BasePreferenceFragment(),
upPreferenceSummary(PreferKey.webDavPassword, getPrefString(PreferKey.webDavPassword)) upPreferenceSummary(PreferKey.webDavPassword, getPrefString(PreferKey.webDavPassword))
upPreferenceSummary(PreferKey.backupPath, getPrefString(PreferKey.backupPath)) upPreferenceSummary(PreferKey.backupPath, getPrefString(PreferKey.backupPath))
findPreference<io.legado.app.ui.widget.prefs.Preference>("web_dav_restore") findPreference<io.legado.app.ui.widget.prefs.Preference>("web_dav_restore")
?.onLongClick = { restoreDir.launch() } ?.onLongClick { restoreDir.launch(); true }
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

@ -23,7 +23,7 @@ import kotlin.math.roundToInt
class Preference(context: Context, attrs: AttributeSet) : class Preference(context: Context, attrs: AttributeSet) :
androidx.preference.Preference(context, attrs) { androidx.preference.Preference(context, attrs) {
var onLongClick: (() -> Unit)? = null private var onLongClick: ((preference: Preference) -> Boolean)? = null
private val isBottomBackground: Boolean private val isBottomBackground: Boolean
init { init {
@ -117,8 +117,12 @@ class Preference(context: Context, attrs: AttributeSet) :
) )
super.onBindViewHolder(holder) super.onBindViewHolder(holder)
holder.itemView.onLongClick { holder.itemView.onLongClick {
onLongClick?.invoke() onLongClick?.invoke(this)
} }
} }
fun onLongClick(listener: (preference: Preference) -> Boolean) {
onLongClick = listener
}
} }

Loading…
Cancel
Save