This commit is contained in:
Horis
2025-04-30 17:47:07 +08:00
parent 96efb19de5
commit 15405cc716
2 changed files with 9 additions and 7 deletions
@@ -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 +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))
}
}