pull/737/head
gedoor 4 years ago
parent d0374904a1
commit e58cb1f0cc
  1. 13
      app/src/main/java/io/legado/app/base/adapter/DiffRecyclerAdapter.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  3. 7
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt
  4. 1
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  5. 7
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt

@ -16,12 +16,14 @@ import kotlin.collections.ArrayList
*/
@Suppress("unused")
abstract class DiffRecyclerAdapter<ITEM, VB : ViewBinding>(protected val context: Context) :
RecyclerView.Adapter<ItemViewHolder>() {
RecyclerView.Adapter<ItemViewHolder>(), AsyncListDiffer.ListListener<ITEM> {
val inflater: LayoutInflater = LayoutInflater.from(context)
private val asyncListDiffer: AsyncListDiffer<ITEM> by lazy {
AsyncListDiffer(this, diffItemCallback)
AsyncListDiffer(this, diffItemCallback).apply {
addListListener(this@DiffRecyclerAdapter)
}
}
private val lock = Object()
@ -144,6 +146,13 @@ abstract class DiffRecyclerAdapter<ITEM, VB : ViewBinding>(protected val context
final override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {}
override fun onCurrentListChanged(
previousList: MutableList<ITEM>,
currentList: MutableList<ITEM>
) {
}
@Suppress("UNCHECKED_CAST")
final override fun onBindViewHolder(
holder: ItemViewHolder,

@ -152,7 +152,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
adapter = BookSourceAdapter(this, this)
binding.recyclerView.adapter = adapter
// When this page is opened, it is in selection mode
val dragSelectTouchHelper: DragSelectTouchHelper =
val dragSelectTouchHelper =
DragSelectTouchHelper(adapter.dragSelectCallback).setSlideArea(16, 50)
dragSelectTouchHelper.attachToRecyclerView(binding.recyclerView)
dragSelectTouchHelper.activeSlideSelect()
@ -207,7 +207,6 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
else -> data.reversed()
}
adapter.setItems(sourceList)
upCountView()
})
}

@ -147,6 +147,13 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
}
}
override fun onCurrentListChanged(
previousList: MutableList<BookSource>,
currentList: MutableList<BookSource>
) {
callBack.upCountView()
}
private fun showMenu(view: View, position: Int) {
val source = getItem(position) ?: return
val popupMenu = PopupMenu(context, view)

@ -209,7 +209,6 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
}
sourceLiveData?.observe(this, {
adapter.setItems(it)
upCountView()
})
}

@ -128,6 +128,13 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
}
}
override fun onCurrentListChanged(
previousList: MutableList<RssSource>,
currentList: MutableList<RssSource>
) {
callBack.upCountView()
}
fun selectAll() {
getItems().forEach {
selected.add(it)

Loading…
Cancel
Save