[Android] DiffUtil: Implement getItemCount & set CB optional

Geoffrey Métais git at videolan.org
Tue Nov 13 10:38:47 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Nov  2 17:56:05 2018 +0100| [9fa0800e6678576d24fc0aa2b13af4ca21727762] | committer: Geoffrey Métais

DiffUtil: Implement getItemCount & set CB optional

> https://code.videolan.org/videolan/vlc-android/commit/9fa0800e6678576d24fc0aa2b13af4ca21727762
---

 vlc-android/src/org/videolan/vlc/gui/DiffUtilAdapter.kt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/DiffUtilAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/DiffUtilAdapter.kt
index 6d08fc323..7e5c6fa64 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DiffUtilAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/DiffUtilAdapter.kt
@@ -17,7 +17,7 @@ abstract class DiffUtilAdapter<D, VH : androidx.recyclerview.widget.RecyclerView
     private val updateActor = actor<List<D>>(capacity = Channel.CONFLATED) {
         for (list in channel) internalUpdate(list)
     }
-    protected abstract fun onUpdateFinished()
+    protected open fun onUpdateFinished() {}
 
     @MainThread
     fun update (list: List<D>) {
@@ -43,6 +43,8 @@ abstract class DiffUtilAdapter<D, VH : androidx.recyclerview.widget.RecyclerView
 
     open fun getItem(position: Int) = dataset[position]
 
+    override fun getItemCount() = dataset.size
+
     protected open fun detectMoves() = false
 
     protected open fun createCB() = DiffCallback<D>()



More information about the Android mailing list