Horis 1 год назад
Родитель
Сommit
3d5618ff18

+ 1 - 1
app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt

@@ -91,7 +91,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
     override val binding by viewBinding(ActivityBookSourceBinding::inflate)
     override val viewModel by viewModels<BookSourceViewModel>()
     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)

+ 8 - 6
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<BookSourcePart, ItemBookSourceBinding>(context),
+class BookSourceAdapter(
+    context: Context,
+    private val callBack: CallBack,
+    private val recyclerView: RecyclerView
+) : RecyclerAdapter<BookSourcePart, ItemBookSourceBinding>(context),
     ItemTouchCallback.Callback {
 
     private val selected = linkedSetOf<BookSourcePart>()
@@ -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))
         }
     }