mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
Some checks are pending
Test Build / prepare (push) Waiting to run
Test Build / build (app, release) (push) Blocked by required conditions
Test Build / build (app, releaseA) (push) Blocked by required conditions
Test Build / prerelease (push) Blocked by required conditions
Test Build / lanzou (push) Blocked by required conditions
Test Build / test_Branch (push) Blocked by required conditions
Test Build / telegram (push) Blocked by required conditions
Some checks are pending
Test Build / prepare (push) Waiting to run
Test Build / build (app, release) (push) Blocked by required conditions
Test Build / build (app, releaseA) (push) Blocked by required conditions
Test Build / prerelease (push) Blocked by required conditions
Test Build / lanzou (push) Blocked by required conditions
Test Build / test_Branch (push) Blocked by required conditions
Test Build / telegram (push) Blocked by required conditions
This commit is contained in:
@@ -54,6 +54,7 @@ class App : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
CrashHandler(this)
|
||||
LogUtils.init(this)
|
||||
LogUtils.d("App", "onCreate")
|
||||
LogUtils.logDeviceInfo()
|
||||
if (isDebuggable) {
|
||||
|
||||
@@ -197,8 +197,8 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
mLayoutManager.initialPrefetchItemCount = 4
|
||||
mLayoutManager.isItemPrefetchEnabled = true
|
||||
setItemViewCacheSize(AppConfig.preDownloadNum)
|
||||
disabledClickScroll(AppConfig.disableClickScroll)
|
||||
disableMangaScaling(AppConfig.disableMangaScale)
|
||||
setDisableClickScroll(AppConfig.disableClickScroll)
|
||||
setDisableMangaScale(AppConfig.disableMangaScale)
|
||||
setRecyclerViewPreloader(AppConfig.mangaPreDownloadNum)
|
||||
setPreScrollListener { _, _, _, position ->
|
||||
if (mAdapter.isNotEmpty()) {
|
||||
@@ -478,13 +478,13 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
R.id.menu_disable_manga_scale -> {
|
||||
item.isChecked = !item.isChecked
|
||||
AppConfig.disableMangaScale = item.isChecked
|
||||
disableMangaScaling(item.isChecked)
|
||||
setDisableMangaScale(item.isChecked)
|
||||
}
|
||||
|
||||
R.id.menu_disable_click_scroll -> {
|
||||
item.isChecked = !item.isChecked
|
||||
AppConfig.disableClickScroll = item.isChecked
|
||||
disabledClickScroll(item.isChecked)
|
||||
setDisableClickScroll(item.isChecked)
|
||||
}
|
||||
|
||||
R.id.menu_enable_auto_page -> {
|
||||
@@ -594,15 +594,15 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
AppConfig.enableMangaHorizontalScroll
|
||||
}
|
||||
|
||||
private fun disableMangaScaling(disable: Boolean) {
|
||||
private fun setDisableMangaScale(disable: Boolean) {
|
||||
binding.webtoonFrame.disableMangaScale = disable
|
||||
binding.mRecyclerManga.disableMangaScaling = disable
|
||||
binding.mRecyclerManga.disableMangaScale = disable
|
||||
if (disable) {
|
||||
binding.mRecyclerManga.resetZoom()
|
||||
}
|
||||
}
|
||||
|
||||
private fun disabledClickScroll(disable: Boolean) {
|
||||
private fun setDisableClickScroll(disable: Boolean) {
|
||||
binding.webtoonFrame.disabledClickScroll = disable
|
||||
}
|
||||
|
||||
|
||||
@@ -215,8 +215,9 @@ class MangaAdapter(private val context: Context) :
|
||||
}
|
||||
|
||||
override fun getPreloadItems(position: Int): List<Any> {
|
||||
if (isEmpty()) return emptyList()
|
||||
if (position >= getItems().size) return emptyList()
|
||||
if (isEmpty() || position >= getItems().size) {
|
||||
return emptyList()
|
||||
}
|
||||
return getItems().subList(position, position + 1)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.legado.app.ui.book.manga.recyclerview
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.graphics.RectF
|
||||
import android.util.AttributeSet
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.MotionEvent
|
||||
@@ -42,7 +41,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
var doubleTapZoom = true
|
||||
var tapListener: ((MotionEvent) -> Unit)? = null
|
||||
var longTapListener: ((MotionEvent) -> Boolean)? = null
|
||||
var disableMangaScaling = false
|
||||
var disableMangaScale = false
|
||||
|
||||
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
|
||||
halfWidth = MeasureSpec.getSize(widthSpec) / 2
|
||||
@@ -277,7 +276,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
scrollPointerId = ev.getPointerId(0)
|
||||
downX = (ev.x + 0.5f).toInt()
|
||||
downY =(ev.y + 0.5f).toInt()
|
||||
downY = (ev.y + 0.5f).toInt()
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_POINTER_DOWN -> {
|
||||
@@ -287,7 +286,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
if (disableMangaScaling) {
|
||||
if (disableMangaScale) {
|
||||
return super.onTouchEvent(ev)
|
||||
}
|
||||
if (isDoubleTapping && isQuickScaling) {
|
||||
@@ -335,7 +334,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_UP -> {
|
||||
if (isDoubleTapping && !isQuickScaling && !disableMangaScaling) {
|
||||
if (isDoubleTapping && !isQuickScaling && !disableMangaScale) {
|
||||
listener.onDoubleTapConfirmed(ev)
|
||||
}
|
||||
isZoomDragging = false
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.webkit.WebSettings
|
||||
import io.legado.app.BuildConfig
|
||||
@@ -12,6 +13,7 @@ import io.legado.app.help.config.AppConfig
|
||||
import splitties.init.appCtx
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.logging.FileHandler
|
||||
import java.util.logging.Level
|
||||
import java.util.logging.LogRecord
|
||||
import java.util.logging.Logger
|
||||
@@ -23,6 +25,10 @@ object LogUtils {
|
||||
const val TIME_PATTERN = "yy-MM-dd HH:mm:ss.SSS"
|
||||
val logTimeFormat by lazy { SimpleDateFormat(TIME_PATTERN) }
|
||||
|
||||
fun init(context: Context) {
|
||||
fileHandler = createFileHandler(context)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun d(tag: String, msg: String) {
|
||||
logger.log(Level.INFO, "$tag $msg")
|
||||
@@ -47,9 +53,11 @@ object LogUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private val fileHandler by lazy {
|
||||
private var fileHandler: FileHandler? = null
|
||||
|
||||
private fun createFileHandler(context: Context): FileHandler? {
|
||||
try {
|
||||
val root = appCtx.externalCacheDir ?: return@lazy null
|
||||
val root = context.externalCacheDir ?: return null
|
||||
val logFolder = FileUtils.createFolderIfNotExist(root, "logs")
|
||||
val expiredTime = System.currentTimeMillis() - 7.days.inWholeMilliseconds
|
||||
logFolder.listFiles()?.forEach {
|
||||
@@ -59,11 +67,11 @@ object LogUtils {
|
||||
}
|
||||
val date = getCurrentDateStr(TIME_PATTERN)
|
||||
val logPath = FileUtils.getPath(root = logFolder, "appLog-$date.txt")
|
||||
AsyncFileHandler(logPath).apply {
|
||||
return AsyncFileHandler(logPath).apply {
|
||||
formatter = object : java.util.logging.Formatter() {
|
||||
override fun format(record: LogRecord): String {
|
||||
// 设置文件输出格式
|
||||
return (getCurrentDateStr(TIME_PATTERN) + ": " + record.message + "\n")
|
||||
return getCurrentDateStr(TIME_PATTERN) + ": " + record.message + "\n"
|
||||
}
|
||||
}
|
||||
level = if (AppConfig.recordLog) {
|
||||
@@ -75,7 +83,7 @@ object LogUtils {
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
AppLog.putNotSave("创建fileHandler出错\n$e", e)
|
||||
return@lazy null
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user