From 34fea0ce5d738451a9031d92f9ea44b1783de6e1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 20 Oct 2020 21:04:25 +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/anima/RotateLoading.kt | 22 ++++++------------- .../dynamiclayout/DynamicFrameLayout.kt | 5 ++++- .../app/ui/widget/image/CircleImageView.kt | 6 +++-- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt b/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt index 13c4f346d..e587da788 100644 --- a/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt +++ b/app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt @@ -18,9 +18,13 @@ import io.legado.app.utils.dp * Created by Victor on 2015/4/28. */ @Suppress("MemberVisibilityCanBePrivate") -class RotateLoading : View { +class RotateLoading @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : View(context, attrs, defStyleAttr) { - private lateinit var mPaint: Paint + private var mPaint: Paint private var loadingRectF: RectF? = null private var shadowRectF: RectF? = null @@ -55,19 +59,7 @@ class RotateLoading : View { private val hidden = Runnable { this.stopInternal() } - constructor(context: Context) : super(context) { - initView(context, null) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - initView(context, attrs) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - initView(context, attrs) - } - - private fun initView(context: Context, attrs: AttributeSet?) { + init { loadingColor = context.accentColor thisWidth = DEFAULT_WIDTH.dp shadowPosition = DEFAULT_SHADOW_POSITION.dp diff --git a/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/DynamicFrameLayout.kt b/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/DynamicFrameLayout.kt index 683cbc5d9..d3115bdc9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/DynamicFrameLayout.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dynamiclayout/DynamicFrameLayout.kt @@ -13,7 +13,10 @@ import io.legado.app.R import kotlinx.android.synthetic.main.view_dynamic.view.* @Suppress("unused") -class DynamicFrameLayout(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs), ViewSwitcher { +class DynamicFrameLayout @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : FrameLayout(context, attrs), ViewSwitcher { private var errorView: View? = null private var errorImage: AppCompatImageView? = null diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt index 2364deab7..f5781183e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt @@ -25,8 +25,10 @@ import kotlin.math.min import kotlin.math.pow @Suppress("unused", "MemberVisibilityCanBePrivate") -class CircleImageView(context: Context, attrs: AttributeSet) : - AppCompatImageView(context, attrs) { +class CircleImageView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null +) : AppCompatImageView(context, attrs) { private val mDrawableRect = RectF() private val mBorderRect = RectF()