pull/433/head
gedoor 4 years ago
parent 2c40f3c06b
commit 8383ffe63c
  1. 1
      app/src/main/java/io/legado/app/constant/AppPattern.kt
  2. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  3. 6
      app/src/main/java/io/legado/app/ui/widget/image/PhotoView.kt
  4. 1
      app/src/main/java/io/legado/app/ui/widget/image/photo/Info.kt
  5. 20
      app/src/main/java/io/legado/app/ui/widget/image/photo/RotateGestureDetector.kt
  6. 3
      app/src/main/java/io/legado/app/utils/ACache.kt

@ -2,6 +2,7 @@ package io.legado.app.constant
import java.util.regex.Pattern import java.util.regex.Pattern
@Suppress("RegExpRedundantEscape")
object AppPattern { object AppPattern {
val JS_PATTERN: Pattern = val JS_PATTERN: Pattern =
Pattern.compile("(<js>[\\w\\W]*?</js>|@js:[\\w\\W]*$)", Pattern.CASE_INSENSITIVE) Pattern.compile("(<js>[\\w\\W]*?</js>|@js:[\\w\\W]*$)", Pattern.CASE_INSENSITIVE)

@ -20,7 +20,7 @@ import kotlin.collections.HashMap
* 统一解析接口 * 统一解析接口
*/ */
@Keep @Keep
@Suppress("unused") @Suppress("unused", "RegExpRedundantEscape")
class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
var chapter: BookChapter? = null var chapter: BookChapter? = null
private var content: Any? = null private var content: Any? = null

@ -24,6 +24,7 @@ import kotlin.math.abs
import kotlin.math.roundToInt import kotlin.math.roundToInt
@Suppress("UNUSED_PARAMETER", "unused", "MemberVisibilityCanBePrivate")
@SuppressLint("AppCompatCustomView") @SuppressLint("AppCompatCustomView")
class PhotoView : ImageView { class PhotoView : ImageView {
val MIN_ROTATE = 35 val MIN_ROTATE = 35
@ -197,6 +198,7 @@ class PhotoView : ImageView {
MAX_ANIM_FROM_WAITE = wait MAX_ANIM_FROM_WAITE = wait
} }
@SuppressLint("UseCompatLoadingForDrawables")
override fun setImageResource(resId: Int) { override fun setImageResource(resId: Int) {
var drawable: Drawable? = null var drawable: Drawable? = null
try { try {
@ -832,7 +834,7 @@ class PhotoView : ImageView {
} }
private inner class Transform internal constructor() : Runnable { private inner class Transform : Runnable {
var isRunning = false var isRunning = false
var mTranslateScroller: OverScroller var mTranslateScroller: OverScroller
var mFlingScroller: OverScroller var mFlingScroller: OverScroller
@ -1230,7 +1232,7 @@ class PhotoView : ImageView {
val scale = if (scaleX > scaleY) scaleX else scaleY val scale = if (scaleX > scaleY) scaleX else scaleY
mAnimMatrix.postRotate(mDegrees, mScaleCenter.x, mScaleCenter.y) mAnimMatrix.postRotate(mDegrees, mScaleCenter.x, mScaleCenter.y)
mAnimMatrix.mapRect(mImgRect, mBaseRect) mAnimMatrix.mapRect(mImgRect, mBaseRect)
mDegrees = mDegrees % 360 mDegrees %= 360
mTranslate.withTranslate( mTranslate.withTranslate(
0, 0,
0, 0,

@ -6,6 +6,7 @@ import android.graphics.RectF
import android.widget.ImageView import android.widget.ImageView
@Suppress("MemberVisibilityCanBePrivate")
class Info( class Info(
rect: RectF, rect: RectF,
img: RectF, img: RectF,

@ -26,26 +26,26 @@ class RotateGestureDetector(private val mListener: OnRotateListener) {
MotionEvent.ACTION_MOVE -> if (event.pointerCount > 1) { MotionEvent.ACTION_MOVE -> if (event.pointerCount > 1) {
mCurrSlope = calculateSlope(event) mCurrSlope = calculateSlope(event)
val currDegrees = Math.toDegrees(atan(mCurrSlope.toDouble())); val currDegrees = Math.toDegrees(atan(mCurrSlope.toDouble()))
val prevDegrees = Math.toDegrees(atan(mPrevSlope.toDouble())); val prevDegrees = Math.toDegrees(atan(mPrevSlope.toDouble()))
val deltaSlope = currDegrees - prevDegrees; val deltaSlope = currDegrees - prevDegrees
if (abs(deltaSlope) <= MAX_DEGREES_STEP) { 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 { private fun calculateSlope(event: MotionEvent): Float {
val x1 = event.getX(0); val x1 = event.getX(0)
val y1 = event.getY(0); val y1 = event.getY(0)
val x2 = event.getX(1); val x2 = event.getX(1)
val y2 = event.getY(1); val y2 = event.getY(1)
return (y2 - y1) / (x2 - x1); return (y2 - y1) / (x2 - x1)
} }
} }

@ -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) { class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) {
companion object { companion object {
@ -543,6 +543,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
return null return null
} }
@Suppress("SameParameterValue")
private fun indexOf(data: ByteArray, c: Char): Int { private fun indexOf(data: ByteArray, c: Char): Int {
for (i in data.indices) { for (i in data.indices) {
if (data[i] == c.toByte()) { if (data[i] == c.toByte()) {

Loading…
Cancel
Save