pull/436/head
gedoor 4 years ago
parent cda1905108
commit 462f6b7d20
  1. 41
      app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBar.kt

@ -17,15 +17,7 @@ import java.lang.reflect.InvocationTargetException
import java.lang.reflect.Method import java.lang.reflect.Method
@Suppress("SameParameterValue") @Suppress("SameParameterValue")
class VerticalSeekBar @JvmOverloads constructor( class VerticalSeekBar : AppCompatSeekBar {
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = androidx.appcompat.R.attr.seekBarStyle
) : AppCompatSeekBar(
context,
attrs,
defStyleAttr
) {
private var mIsDragging: Boolean = false private var mIsDragging: Boolean = false
private var mThumb: Drawable? = null private var mThumb: Drawable? = null
@ -62,13 +54,38 @@ class VerticalSeekBar @JvmOverloads constructor(
} }
} }
init { constructor(context: Context) : super(context) {
initialize(context, null, 0, 0)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
initialize(context, attrs, 0, 0)
}
constructor(
context: Context,
attrs: AttributeSet,
defStyle: Int
) : super(context, attrs, defStyle) {
initialize(context, attrs, defStyle, 0)
}
private fun initialize(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) {
ATH.setTint(this, ThemeStore.accentColor(context)) ATH.setTint(this, ThemeStore.accentColor(context))
ViewCompat.setLayoutDirection(this, ViewCompat.LAYOUT_DIRECTION_LTR) ViewCompat.setLayoutDirection(this, ViewCompat.LAYOUT_DIRECTION_LTR)
if (attrs != null) { if (attrs != null) {
val a = val a = context.obtainStyledAttributes(
context.obtainStyledAttributes(attrs, R.styleable.VerticalSeekBar, defStyleAttr, 0) attrs,
R.styleable.VerticalSeekBar,
defStyleAttr,
defStyleRes
)
val rotationAngle = a.getInteger(R.styleable.VerticalSeekBar_seekBarRotation, 0) val rotationAngle = a.getInteger(R.styleable.VerticalSeekBar_seekBarRotation, 0)
if (isValidRotationAngle(rotationAngle)) { if (isValidRotationAngle(rotationAngle)) {
mRotationAngle = rotationAngle mRotationAngle = rotationAngle

Loading…
Cancel
Save