From 8383ffe63c849607fe3b97126ca38aef3efdbae9 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 18 Oct 2020 18:23:02 +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 --- .../java/io/legado/app/constant/AppPattern.kt | 1 + .../app/model/analyzeRule/AnalyzeRule.kt | 2 +- .../legado/app/ui/widget/image/PhotoView.kt | 6 ++++-- .../legado/app/ui/widget/image/photo/Info.kt | 1 + .../image/photo/RotateGestureDetector.kt | 20 +++++++++---------- .../main/java/io/legado/app/utils/ACache.kt | 3 ++- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/AppPattern.kt b/app/src/main/java/io/legado/app/constant/AppPattern.kt index 19fa46a41..0866b42d4 100644 --- a/app/src/main/java/io/legado/app/constant/AppPattern.kt +++ b/app/src/main/java/io/legado/app/constant/AppPattern.kt @@ -2,6 +2,7 @@ package io.legado.app.constant import java.util.regex.Pattern +@Suppress("RegExpRedundantEscape") object AppPattern { val JS_PATTERN: Pattern = Pattern.compile("([\\w\\W]*?|@js:[\\w\\W]*$)", Pattern.CASE_INSENSITIVE) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index cb8b9c6b9..8fb5e2c0f 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -20,7 +20,7 @@ import kotlin.collections.HashMap * 统一解析接口 */ @Keep -@Suppress("unused") +@Suppress("unused", "RegExpRedundantEscape") class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { var chapter: BookChapter? = null private var content: Any? = null diff --git a/app/src/main/java/io/legado/app/ui/widget/image/PhotoView.kt b/app/src/main/java/io/legado/app/ui/widget/image/PhotoView.kt index 44f108e91..5a2c7588f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/PhotoView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/PhotoView.kt @@ -24,6 +24,7 @@ import kotlin.math.abs import kotlin.math.roundToInt +@Suppress("UNUSED_PARAMETER", "unused", "MemberVisibilityCanBePrivate") @SuppressLint("AppCompatCustomView") class PhotoView : ImageView { val MIN_ROTATE = 35 @@ -197,6 +198,7 @@ class PhotoView : ImageView { MAX_ANIM_FROM_WAITE = wait } + @SuppressLint("UseCompatLoadingForDrawables") override fun setImageResource(resId: Int) { var drawable: Drawable? = null try { @@ -832,7 +834,7 @@ class PhotoView : ImageView { } - private inner class Transform internal constructor() : Runnable { + private inner class Transform : Runnable { var isRunning = false var mTranslateScroller: OverScroller var mFlingScroller: OverScroller @@ -1230,7 +1232,7 @@ class PhotoView : ImageView { val scale = if (scaleX > scaleY) scaleX else scaleY mAnimMatrix.postRotate(mDegrees, mScaleCenter.x, mScaleCenter.y) mAnimMatrix.mapRect(mImgRect, mBaseRect) - mDegrees = mDegrees % 360 + mDegrees %= 360 mTranslate.withTranslate( 0, 0, diff --git a/app/src/main/java/io/legado/app/ui/widget/image/photo/Info.kt b/app/src/main/java/io/legado/app/ui/widget/image/photo/Info.kt index abd6f9080..6ce1adfc6 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/photo/Info.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/photo/Info.kt @@ -6,6 +6,7 @@ import android.graphics.RectF import android.widget.ImageView +@Suppress("MemberVisibilityCanBePrivate") class Info( rect: RectF, img: RectF, diff --git a/app/src/main/java/io/legado/app/ui/widget/image/photo/RotateGestureDetector.kt b/app/src/main/java/io/legado/app/ui/widget/image/photo/RotateGestureDetector.kt index 77c8c232d..7dddbebbf 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/photo/RotateGestureDetector.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/photo/RotateGestureDetector.kt @@ -26,26 +26,26 @@ class RotateGestureDetector(private val mListener: OnRotateListener) { MotionEvent.ACTION_MOVE -> if (event.pointerCount > 1) { mCurrSlope = calculateSlope(event) - val currDegrees = Math.toDegrees(atan(mCurrSlope.toDouble())); - val prevDegrees = Math.toDegrees(atan(mPrevSlope.toDouble())); + val currDegrees = Math.toDegrees(atan(mCurrSlope.toDouble())) + val prevDegrees = Math.toDegrees(atan(mPrevSlope.toDouble())) - val deltaSlope = currDegrees - prevDegrees; + val deltaSlope = currDegrees - prevDegrees if (abs(deltaSlope) <= MAX_DEGREES_STEP) { - mListener.onRotate(deltaSlope.toFloat(), (x2 + x1) / 2, (y2 + y1) / 2); + mListener.onRotate(deltaSlope.toFloat(), (x2 + x1) / 2, (y2 + y1) / 2) } - mPrevSlope = mCurrSlope; + mPrevSlope = mCurrSlope } } } private fun calculateSlope(event: MotionEvent): Float { - val x1 = event.getX(0); - val y1 = event.getY(0); - val x2 = event.getX(1); - val y2 = event.getY(1); - return (y2 - y1) / (x2 - x1); + val x1 = event.getX(0) + val y1 = event.getY(0) + val x2 = event.getX(1) + val y2 = event.getY(1) + return (y2 - y1) / (x2 - x1) } } diff --git a/app/src/main/java/io/legado/app/utils/ACache.kt b/app/src/main/java/io/legado/app/utils/ACache.kt index 03a330d6a..6a0a0b9fb 100644 --- a/app/src/main/java/io/legado/app/utils/ACache.kt +++ b/app/src/main/java/io/legado/app/utils/ACache.kt @@ -22,7 +22,7 @@ import kotlin.math.min /** * 本地缓存 */ -@Suppress("unused") +@Suppress("unused", "MemberVisibilityCanBePrivate") class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) { companion object { @@ -543,6 +543,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) return null } + @Suppress("SameParameterValue") private fun indexOf(data: ByteArray, c: Char): Int { for (i in data.indices) { if (data[i] == c.toByte()) {