优化
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user