[Android] Sorted videos call

Geoffrey Métais git at videolan.org
Wed Apr 4 18:34:42 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 23 09:20:04 2018 +0100| [32df50af9eb3ffe03904e711af3e01172590e226] | committer: Geoffrey Métais

Sorted videos call

> https://code.videolan.org/videolan/vlc-android/commit/32df50af9eb3ffe03904e711af3e01172590e226
---

 medialibrary/jni/medialibrary.cpp                           |  7 +++++++
 .../src/org/videolan/medialibrary/Medialibrary.java         |  6 ++++++
 vlc-android/src/org/videolan/vlc/util/Constants.java        | 13 +++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 052e39ff3..95a618b8b 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -276,6 +276,12 @@ getVideos(JNIEnv* env, jobject thiz)
     return getInternalVideos(env, thiz);
 }
 
+jobjectArray
+getSortedVideos(JNIEnv* env, jobject thiz, jint sortingCriteria, jboolean desc)
+{
+    return getInternalVideos(env, thiz, static_cast<medialibrary::SortingCriteria>(sortingCriteria), desc);
+}
+
 jobjectArray
 getRecentVideos(JNIEnv* env, jobject thiz)
 {
@@ -784,6 +790,7 @@ static JNINativeMethod methods[] = {
     {"nativeAddToHistory", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)addToHistory },
     {"nativeClearHistory", "()Z", (void*)clearHistory },
     {"nativeGetVideos", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getVideos },
+    {"nativeGetSortedVideos", "(IZ)[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getSortedVideos },
     {"nativeGetRecentVideos", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getRecentVideos },
     {"nativeGetAudio", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getAudio },
     {"nativeGetRecentAudio", "()[Lorg/videolan/medialibrary/media/MediaWrapper;", (void*)getRecentAudio },
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 29f546368..3ac218d8d 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -156,6 +156,11 @@ public class Medialibrary {
         return mIsInitiated ? nativeGetVideos() : new MediaWrapper[0];
     }
 
+    @WorkerThread
+    public MediaWrapper[] getVideos(int sort, boolean desc) {
+        return mIsInitiated ? nativeGetSortedVideos(sort, desc) : new MediaWrapper[0];
+    }
+
     @WorkerThread
     public MediaWrapper[] getRecentVideos() {
         return mIsInitiated ? nativeGetRecentVideos() : new MediaWrapper[0];
@@ -634,6 +639,7 @@ public class Medialibrary {
     private native MediaWrapper nativeGetMediaFromMrl(String mrl);
     private native MediaWrapper nativeAddMedia(String mrl);
     private native MediaWrapper[] nativeGetVideos();
+    private native MediaWrapper[] nativeGetSortedVideos(int sort, boolean desc);
     private native MediaWrapper[] nativeGetRecentVideos();
     private native MediaWrapper[] nativeGetAudio();
     private native MediaWrapper[] nativeGetRecentAudio();
diff --git a/vlc-android/src/org/videolan/vlc/util/Constants.java b/vlc-android/src/org/videolan/vlc/util/Constants.java
index bc1ae73af..27ce5995e 100644
--- a/vlc-android/src/org/videolan/vlc/util/Constants.java
+++ b/vlc-android/src/org/videolan/vlc/util/Constants.java
@@ -88,4 +88,17 @@ public class Constants {
 
     // AUDIO category
     public final static String KEY_AUDIO_CURRENT_TAB = "key_audio_current_tab";
+
+    // Sorting
+
+    public final static int SORT_DEFAULT = 0;
+    public final static int SORT_ALPHA = 1;
+    public final static int SORT_DURATION = 2;
+    public final static int SORT_INSERTIONDATE = 3;
+    public final static int SORT_LASTMODIFICATIONDATE = 4;
+    public final static int SORT_RELEASEDATE = 5;
+    public final static int SORT_FILESIZE = 6;
+    public final static int SORT_ARTIST = 7;
+    public final static int SORT_PLAYCOUNT = 8;
+    public final static int SORT_ALBUM = 9;
 }



More information about the Android mailing list