From 15405cc7160decae289b4ed5709f52e823aef342 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Wed, 30 Apr 2025 17:47:07 +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 --- .../ui/book/source/manage/BookSourceActivity.kt | 2 +- .../app/ui/book/source/manage/BookSourceAdapter.kt | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 786151ad4..c62087810 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -91,7 +91,7 @@ class BookSourceActivity : VMBaseActivity() private val importRecordKey = "bookSourceRecordKey" - private val adapter by lazy { BookSourceAdapter(this, this) } + private val adapter by lazy { BookSourceAdapter(this, this, binding.recyclerView) } private val itemTouchCallback by lazy { ItemTouchCallback(adapter) } private val searchView: SearchView by lazy { binding.titleBar.findViewById(R.id.search_view) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index 6f18074a3..5a53dc67d 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import android.widget.ImageView import android.widget.PopupMenu import androidx.core.os.bundleOf +import androidx.core.view.doOnLayout import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import io.legado.app.R @@ -29,8 +30,11 @@ import io.legado.app.utils.visible import java.util.Collections -class BookSourceAdapter(context: Context, val callBack: CallBack) : - RecyclerAdapter(context), +class BookSourceAdapter( + context: Context, + private val callBack: CallBack, + private val recyclerView: RecyclerView +) : RecyclerAdapter(context), ItemTouchCallback.Callback { private val selected = linkedSetOf() @@ -154,10 +158,8 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : override fun onCurrentListChanged() { callBack.upCountView() - if (showSourceHost) { - handler.post { - notifyItemRangeChanged(0, itemCount, bundleOf("upSourceHost" to null)) - } + recyclerView.doOnLayout { + notifyItemRangeChanged(0, itemCount, bundleOf("upSourceHost" to null)) } }