[Android] Add add(items) for sorted incremental updates
Geoffrey Métais
git at videolan.org
Thu Jul 27 17:41:23 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jul 27 17:39:50 2017 +0200| [04cf17f8c24b007d8ff2ba1b541370d03bf24df5] | committer: Geoffrey Métais
Add add(items) for sorted incremental updates
> https://code.videolan.org/videolan/vlc-android/commit/04cf17f8c24b007d8ff2ba1b541370d03bf24df5
---
.../src/org/videolan/vlc/SortableAdapter.java | 26 ++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/SortableAdapter.java b/vlc-android/src/org/videolan/vlc/SortableAdapter.java
index 3265e04ee..8a7959213 100644
--- a/vlc-android/src/org/videolan/vlc/SortableAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/SortableAdapter.java
@@ -5,6 +5,7 @@ import android.support.v7.widget.RecyclerView;
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.vlc.gui.BaseQueuedAdapter;
import org.videolan.vlc.util.MediaLibraryItemComparator;
+import org.videolan.vlc.util.Util;
import java.util.ArrayList;
import java.util.Collections;
@@ -72,4 +73,29 @@ public abstract class SortableAdapter<T extends MediaLibraryItem, VH extends Rec
Collections.sort(list, sMediaComparator);
return list;
}
+
+ public void add(final T[] items) {
+ if (!Util.isArrayEmpty(items)) {
+ VLCApplication.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ if (getSortBy() == MediaLibraryItemComparator.SORT_DEFAULT)
+ sMediaComparator.sortBy(getDefaultSort(), 1);
+ final ArrayList<T> list = new ArrayList<>(peekLast());
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ Util.insertOrUdpate(list, items);
+ VLCApplication.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ update(list);
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+ }
}
More information about the Android
mailing list