From b0f740dc820a96dbd7fd5721e0a77bf86fb7af8a Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 20 Oct 2020 21:11:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/widget/seekbar/VerticalSeekBar.kt | 40 +++++-------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBar.kt b/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBar.kt index ab4509954..c700f4794 100644 --- a/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/seekbar/VerticalSeekBar.kt @@ -17,7 +17,15 @@ import java.lang.reflect.InvocationTargetException import java.lang.reflect.Method @Suppress("SameParameterValue") -class VerticalSeekBar : AppCompatSeekBar { +class VerticalSeekBar @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyle: Int = 0 +) : AppCompatSeekBar( + context, + attrs, + defStyle +) { private var mIsDragging: Boolean = false private var mThumb: Drawable? = null @@ -54,38 +62,12 @@ class VerticalSeekBar : AppCompatSeekBar { } } - 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 - ) { + init { ATH.setTint(this, ThemeStore.accentColor(context)) ViewCompat.setLayoutDirection(this, ViewCompat.LAYOUT_DIRECTION_LTR) if (attrs != null) { - val a = context.obtainStyledAttributes( - attrs, - R.styleable.VerticalSeekBar, - defStyleAttr, - defStyleRes - ) + val a = context.obtainStyledAttributes(attrs, R.styleable.VerticalSeekBar, defStyle, 0) val rotationAngle = a.getInteger(R.styleable.VerticalSeekBar_seekBarRotation, 0) if (isValidRotationAngle(rotationAngle)) { mRotationAngle = rotationAngle