Update AdapterDelegates library
This commit is contained in:
@@ -93,8 +93,8 @@ dependencies {
|
|||||||
implementation 'com.squareup.okio:okio:2.10.0'
|
implementation 'com.squareup.okio:okio:2.10.0'
|
||||||
implementation 'org.jsoup:jsoup:1.14.3'
|
implementation 'org.jsoup:jsoup:1.14.3'
|
||||||
|
|
||||||
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.0'
|
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.1'
|
||||||
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:4.3.0'
|
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:4.3.1'
|
||||||
|
|
||||||
implementation 'io.insert-koin:koin-android:3.1.3'
|
implementation 'io.insert-koin:koin-android:3.1.3'
|
||||||
implementation 'io.coil-kt:coil-base:1.4.0'
|
implementation 'io.coil-kt:coil-base:1.4.0'
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.list
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
@Deprecated("")
|
|
||||||
class AdapterUpdater<T>(oldList: List<T>, newList: List<T>, getId: (T) -> Long) {
|
|
||||||
|
|
||||||
private val diff = DiffUtil.calculateDiff(object : DiffUtil.Callback() {
|
|
||||||
|
|
||||||
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) =
|
|
||||||
getId(oldList[oldItemPosition]) == getId(newList[newItemPosition])
|
|
||||||
|
|
||||||
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) =
|
|
||||||
Objects.equals(oldList[oldItemPosition], newList[newItemPosition])
|
|
||||||
|
|
||||||
override fun getOldListSize() = oldList.size
|
|
||||||
|
|
||||||
override fun getNewListSize() = newList.size
|
|
||||||
})
|
|
||||||
|
|
||||||
operator fun invoke(adapter: RecyclerView.Adapter<*>) {
|
|
||||||
diff.dispatchUpdatesTo(adapter)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,10 +19,6 @@ class ChaptersAdapter(
|
|||||||
return items[position].chapter.id
|
return items[position].chapter.id
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setItems(newItems: List<ChapterListItem>, callback: Runnable) {
|
|
||||||
differ.submitList(newItems, callback)
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DiffCallback : DiffUtil.ItemCallback<ChapterListItem>() {
|
private class DiffCallback : DiffUtil.ItemCallback<ChapterListItem>() {
|
||||||
|
|
||||||
override fun areItemsTheSame(oldItem: ChapterListItem, newItem: ChapterListItem): Boolean {
|
override fun areItemsTheSame(oldItem: ChapterListItem, newItem: ChapterListItem): Boolean {
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ class MangaListAdapter(
|
|||||||
.addDelegate(ITEM_TYPE_FILTER, currentFilterAD(onTagRemoveClick))
|
.addDelegate(ITEM_TYPE_FILTER, currentFilterAD(onTagRemoveClick))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setItems(list: List<ListModel>, commitCallback: Runnable) {
|
|
||||||
differ.submitList(list, commitCallback)
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DiffCallback : DiffUtil.ItemCallback<ListModel>() {
|
private class DiffCallback : DiffUtil.ItemCallback<ListModel>() {
|
||||||
|
|
||||||
override fun areItemsTheSame(oldItem: ListModel, newItem: ListModel) = when {
|
override fun areItemsTheSame(oldItem: ListModel, newItem: ListModel) = when {
|
||||||
|
|||||||
@@ -47,10 +47,6 @@ abstract class BaseReaderAdapter<H : BasePageHolder<*>>(
|
|||||||
viewType: Int
|
viewType: Int
|
||||||
): H = onCreateViewHolder(parent, loader, settings, exceptionResolver)
|
): H = onCreateViewHolder(parent, loader, settings, exceptionResolver)
|
||||||
|
|
||||||
fun setItems(items: List<ReaderPage>, callback: Runnable) {
|
|
||||||
differ.submitList(items, callback)
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun setItems(items: List<ReaderPage>) = suspendCoroutine<Unit> { cont ->
|
suspend fun setItems(items: List<ReaderPage>) = suspendCoroutine<Unit> { cont ->
|
||||||
differ.submitList(items) {
|
differ.submitList(items) {
|
||||||
cont.resume(Unit)
|
cont.resume(Unit)
|
||||||
|
|||||||
Reference in New Issue
Block a user