From e06cc889013113ff2ba4a2cbe20d9ea28ee8968a Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Sun, 25 Aug 2024 16:58:51 +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 --- .../io/legado/app/ui/main/MainViewModel.kt | 7 +++++++ .../main/bookshelf/BaseBookshelfFragment.kt | 15 +++++++++++++- .../bookshelf/style1/books/BooksFragment.kt | 20 ++++++++++++++++--- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index 33a93e85d72d..fc8d40e0114c 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -3,6 +3,7 @@ package io.legado.app.ui.main import android.app.Application import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope +import androidx.recyclerview.widget.RecyclerView.RecycledViewPool import io.legado.app.base.BaseViewModel import io.legado.app.constant.AppConst import io.legado.app.constant.AppLog @@ -52,6 +53,12 @@ class MainViewModel(application: Application) : BaseViewModel(application) { val onUpBooksLiveData = MutableLiveData() private var upTocJob: Job? = null private var cacheBookJob: Job? = null + val booksListRecycledViewPool = RecycledViewPool().apply { + setMaxRecycledViews(0, 30) + } + val booksGridRecycledViewPool = RecycledViewPool().apply { + setMaxRecycledViews(0, 100) + } override fun onCleared() { super.onCleared() diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt index f371a8706a10..e119eff75294 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt @@ -28,7 +28,15 @@ import io.legado.app.ui.file.HandleFileContract import io.legado.app.ui.main.MainFragmentInterface import io.legado.app.ui.main.MainViewModel import io.legado.app.ui.widget.dialog.WaitDialog -import io.legado.app.utils.* +import io.legado.app.utils.checkByIndex +import io.legado.app.utils.getCheckedIndex +import io.legado.app.utils.isAbsUrl +import io.legado.app.utils.postEvent +import io.legado.app.utils.readText +import io.legado.app.utils.sendToClip +import io.legado.app.utils.showDialogFragment +import io.legado.app.utils.startActivity +import io.legado.app.utils.toastOnUi abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment(layoutId), MainFragmentInterface { @@ -198,6 +206,11 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment