aboutsummaryrefslogtreecommitdiff
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
parent4919fb3ac43ba54930d93f535a158787f1737456 (diff)
downloadkau-ab73dc59a302651b46b07329cb2d8303e3ea36dd.tar.gz
kau-ab73dc59a302651b46b07329cb2d8303e3ea36dd.tar.bz2
kau-ab73dc59a302651b46b07329cb2d8303e3ea36dd.zip
Allow diffcallback customization
-rw-r--r--.idea/codeStyles/codeStyleConfig.xml4
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/SingleFastAdapter.kt13
2 files changed, 13 insertions, 4 deletions
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
index 0f7bc51..a55e7a1 100644
--- a/.idea/codeStyles/codeStyleConfig.xml
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -1,5 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
-</component>
+</component> \ No newline at end of file
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)
+ }
}
}