Disable swiping on switch in SwitchSettingsPreference
This commit is contained in:
parent
c741920ec0
commit
147978b932
@ -1,7 +1,9 @@
|
|||||||
package eu.kanade.tachiyomi.widget.preference
|
package eu.kanade.tachiyomi.widget.preference
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.preference.PreferenceViewHolder
|
import androidx.preference.PreferenceViewHolder
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
@ -16,11 +18,17 @@ class SwitchSettingsPreference @JvmOverloads constructor(context: Context, attrs
|
|||||||
widgetLayoutResource = R.layout.pref_settings
|
widgetLayoutResource = R.layout.pref_settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||||
super.onBindViewHolder(holder)
|
super.onBindViewHolder(holder)
|
||||||
|
|
||||||
holder.findViewById(R.id.button).setOnClickListener {
|
holder.findViewById(R.id.button).setOnClickListener {
|
||||||
onSettingsClick?.onClick(it)
|
onSettingsClick?.onClick(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable swiping to align with SwitchPreferenceCompat
|
||||||
|
holder.findViewById(R.id.switchWidget).setOnTouchListener { _, event ->
|
||||||
|
event.actionMasked == MotionEvent.ACTION_MOVE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user