aboutsummaryrefslogtreecommitdiff
path: root/fastadapter/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <allanwang@google.com>2020-01-22 13:33:34 -0800
committerAllan Wang <allanwang@google.com>2020-01-22 13:33:34 -0800
commitab73dc59a302651b46b07329cb2d8303e3ea36dd (patch)
tree0fc715ab8740951561333e166633e9bf996a1dca /fastadapter/src/main/kotlin
parent4919fb3ac43ba54930d93f535a158787f1737456 (diff)
downloadkau-ab73dc59a302651b46b07329cb2d8303e3ea36dd.tar.gz
kau-ab73dc59a302651b46b07329cb2d8303e3ea36dd.tar.bz2
kau-ab73dc59a302651b46b07329cb2d8303e3ea36dd.zip
Allow diffcallback customization
Diffstat (limited to 'fastadapter/src/main/kotlin')
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/SingleFastAdapter.kt13
1 files changed, 11 insertions, 2 deletions
diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/SingleFastAdapter.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/SingleFastAdapter.kt
index e183bde..ebb8048 100644
--- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/SingleFastAdapter.kt
+++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/SingleFastAdapter.kt
@@ -20,6 +20,7 @@ import com.mikepenz.fastadapter.GenericItem
import com.mikepenz.fastadapter.IAdapter
import com.mikepenz.fastadapter.IItemAdapter
import com.mikepenz.fastadapter.adapters.ItemAdapter
+import com.mikepenz.fastadapter.diff.DiffCallback
import com.mikepenz.fastadapter.diff.FastAdapterDiffUtil
/**
@@ -51,7 +52,15 @@ class SingleFastAdapter private constructor(val adapter: ItemAdapter<GenericItem
throw IllegalStateException("SingleFastAdapter only allows one adapter.")
}
- fun setWithDiff(items: List<GenericItem>, detectMoves: Boolean = true) {
- FastAdapterDiffUtil.set(adapter, items, detectMoves)
+ fun setWithDiff(
+ items: List<GenericItem>,
+ detectMoves: Boolean = true,
+ callback: DiffCallback<GenericItem>? = null
+ ) {
+ if (callback == null) {
+ FastAdapterDiffUtil.set(adapter, items, detectMoves)
+ } else {
+ FastAdapterDiffUtil.set(adapter, items, callback, detectMoves)
+ }
}
}