[Android] Insert media in alphabetical order
Geoffrey Métais
git at videolan.org
Wed May 25 18:13:32 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed May 25 18:11:35 2016 +0200| [3a265298bf893ceeca74d4239357da9a458b1cf3] | committer: Geoffrey Métais
Insert media in alphabetical order
> https://code.videolan.org/videolan/vlc-android/commit/3a265298bf893ceeca74d4239357da9a458b1cf3
---
.../org/videolan/vlc/gui/video/VideoListAdapter.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index 9ce1ba8..11c5441 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -38,6 +38,7 @@ import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.SecondaryActivity;
+import org.videolan.vlc.gui.helpers.MediaComparators;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.media.MediaGroup;
import org.videolan.vlc.media.MediaWrapper;
@@ -241,8 +242,22 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
if (position != -1) {
mVideos.set(position, item);
} else {
- position = mVideos.size();
- mVideos.add(item);
+ MediaWrapper mw;
+ for (int i = 0; i < mVideos.size(); ++i) {
+ mw = mVideos.get(i);
+ if (MediaComparators.byName.compare(item, mw) < 0) {
+ position = i;
+ break;
+ }
+ }
+ if (position == -1) {
+ position = mVideos.size();
+ mVideos.add(item);
+ notifyItemChanged(position);
+ } else {
+ mVideos.add(position, item);
+ notifyItemRangeChanged(position, mVideos.size());
+ }
}
notifyItemChanged(position);
}
More information about the Android
mailing list