From f5f8183924f410023f6f191b2d90edf4ebb091df Mon Sep 17 00:00:00 2001 From: crain Date: Mon, 28 Sep 2020 10:49:18 +0500 Subject: [PATCH] UBRD-4736 Add new submit list functionality in DelegationListAdapter --- kotlin-extensions/build.gradle | 2 +- recyclerview-adapters/build.gradle | 2 +- .../touchin/adapters/DelegationListAdapter.kt | 28 ++++++++++++++++++- recyclerview-calendar/build.gradle | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/kotlin-extensions/build.gradle b/kotlin-extensions/build.gradle index 797cd49..381c8e7 100644 --- a/kotlin-extensions/build.gradle +++ b/kotlin-extensions/build.gradle @@ -12,5 +12,5 @@ android { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "androidx.recyclerview:recyclerview:$versions.androidx" + implementation "androidx.recyclerview:recyclerview:$versions.recyclerview" } diff --git a/recyclerview-adapters/build.gradle b/recyclerview-adapters/build.gradle index f4730f9..8cd6c08 100644 --- a/recyclerview-adapters/build.gradle +++ b/recyclerview-adapters/build.gradle @@ -14,5 +14,5 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "androidx.recyclerview:recyclerview:$versions.androidx" + implementation "androidx.recyclerview:recyclerview:$versions.recyclerview" } diff --git a/recyclerview-adapters/src/main/java/ru/touchin/adapters/DelegationListAdapter.kt b/recyclerview-adapters/src/main/java/ru/touchin/adapters/DelegationListAdapter.kt index a47fbe6..d4d54ce 100644 --- a/recyclerview-adapters/src/main/java/ru/touchin/adapters/DelegationListAdapter.kt +++ b/recyclerview-adapters/src/main/java/ru/touchin/adapters/DelegationListAdapter.kt @@ -69,7 +69,33 @@ open class DelegationListAdapter(config: AsyncDifferConfig) : Recy * * @param list The new list to be displayed. */ - fun submitList(list: List) = differ.submitList(list) + fun submitList(list: List?) = differ.submitList(list) + + /** + * Pass a new List to the AdapterHelper. Adapter updates will be computed on a background + * thread. + *

+ * If a List is already present, a diff will be computed asynchronously on a background thread. + * When the diff is computed, it will be applied (dispatched to the {@link ListUpdateCallback}), + * and the new List will be swapped in. + *

+ * The commit callback can be used to know when the List is committed, but note that it + * may not be executed. If List B is submitted immediately after List A, and is + * committed directly, the callback associated with List A will not be run. + * + * @param newList The new List. + * @param commitCallback Optional runnable that is executed when the List is committed, if + * it is committed. + */ + fun submitList(list: List, commitCallback: () -> Unit) = differ.submitList(list, commitCallback) + + /** + * Same as [submitList] with fast simple remove all items of a previous list + */ + fun replaceList(list: List) { + submitList(null) + submitList(list) + } /** * Get the current List - any diffing to present this list has already been computed and diff --git a/recyclerview-calendar/build.gradle b/recyclerview-calendar/build.gradle index 09ee166..9238c62 100644 --- a/recyclerview-calendar/build.gradle +++ b/recyclerview-calendar/build.gradle @@ -12,5 +12,5 @@ dependencies { api project(":logging") api 'net.danlew:android.joda:2.9.9.4' - implementation "androidx.recyclerview:recyclerview:$versions.androidx" + implementation "androidx.recyclerview:recyclerview:$versions.recyclerview" }