[Android] JNI: regroup and regroupAll
Nicolas Pomepuy
git at videolan.org
Tue Apr 21 10:38:50 CEST 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Apr 21 10:38:49 2020 +0200| [f6808e06704c2d6813ab20999e7d2b20d7941df0] | committer: Geoffrey Métais
JNI: regroup and regroupAll
> https://code.videolan.org/videolan/vlc-android/commit/f6808e06704c2d6813ab20999e7d2b20d7941df0
---
medialibrary/jni/AndroidMediaLibrary.cpp | 13 +++++++++++++
medialibrary/jni/AndroidMediaLibrary.h | 2 ++
medialibrary/jni/medialibrary.cpp | 13 +++++++++++++
.../src/org/videolan/medialibrary/MedialibraryImpl.java | 14 ++++++++++++++
.../org/videolan/medialibrary/interfaces/Medialibrary.java | 4 ++++
.../org/videolan/medialibrary/stubs/StubMedialibrary.java | 10 ++++++++++
6 files changed, 56 insertions(+)
diff --git a/medialibrary/jni/AndroidMediaLibrary.cpp b/medialibrary/jni/AndroidMediaLibrary.cpp
index 610c3cfc9..18ff585b7 100644
--- a/medialibrary/jni/AndroidMediaLibrary.cpp
+++ b/medialibrary/jni/AndroidMediaLibrary.cpp
@@ -590,6 +590,19 @@ AndroidMediaLibrary::createMediaGroup( std::string name )
return p_ml->createMediaGroup(name);
}
+bool
+AndroidMediaLibrary::regroupAll()
+{
+ return p_ml->regroupAll();
+}
+
+bool
+AndroidMediaLibrary::regroup(int64_t mediaId)
+{
+ auto media = p_ml->media(mediaId);
+ return media != nullptr && media->regroup();
+}
+
medialibrary::MediaGroupPtr
AndroidMediaLibrary::createMediaGroup( const std::vector<int64_t> mediaIds )
{
diff --git a/medialibrary/jni/AndroidMediaLibrary.h b/medialibrary/jni/AndroidMediaLibrary.h
index b2b557e92..54b7605ab 100644
--- a/medialibrary/jni/AndroidMediaLibrary.h
+++ b/medialibrary/jni/AndroidMediaLibrary.h
@@ -115,6 +115,8 @@ public:
bool groupDestroy(const int64_t groupId );
medialibrary::MediaGroupPtr createMediaGroup( std::string name );
medialibrary::MediaGroupPtr createMediaGroup( std::vector<int64_t> mediaIds );
+ bool regroupAll( );
+ bool regroup(int64_t mediaId);
void onMediaGroupsModified( std::set<int64_t> mediaGroupsIds );
void onMediaGroupsDeleted( std::set<int64_t> mediaGroupsIds );
void onBookmarksAdded( std::vector<medialibrary::BookmarkPtr> );
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 1acbbb187..b7ad974b3 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -1933,6 +1933,17 @@ createMediaGroup(JNIEnv* env, jobject thiz, jlongArray mediaIds)
return group != nullptr ? convertVideoGroupObject(env, &ml_fields, group) : nullptr;
}
+jboolean regroupAll(JNIEnv* env, jobject thiz)
+{
+ return MediaLibrary_getInstance(env, thiz)->regroupAll();
+}
+
+jboolean
+regroup(JNIEnv* env, jobject thiz, jlong id)
+{
+ return MediaLibrary_getInstance(env, thiz)->regroup((int64_t)id);
+}
+
/*
* JNI stuff
*/
@@ -2020,6 +2031,8 @@ static JNINativeMethod methods[] = {
{"nativeGetVideoGroupsCount", "()I", (void*)videoGroupsCount },
{"nativeCreateGroupByName", "(Ljava/lang/String;)Lorg/videolan/medialibrary/interfaces/media/VideoGroup;", (void*)createMediaGroupByName },
{"nativeCreateGroup", "([J)Lorg/videolan/medialibrary/interfaces/media/VideoGroup;", (void*)createMediaGroup },
+ {"nativeRegroupAll", "()Z", (void*)regroupAll },
+ {"nativeRegroup", "(J)Z", (void*)regroup },
};
diff --git a/medialibrary/src/org/videolan/medialibrary/MedialibraryImpl.java b/medialibrary/src/org/videolan/medialibrary/MedialibraryImpl.java
index 878f3c872..07e9a598b 100644
--- a/medialibrary/src/org/videolan/medialibrary/MedialibraryImpl.java
+++ b/medialibrary/src/org/videolan/medialibrary/MedialibraryImpl.java
@@ -240,6 +240,16 @@ public class MedialibraryImpl extends Medialibrary {
return mIsInitiated && (ids.length != 0) ? nativeCreateGroup(ids) : null;
}
+ @Override
+ public boolean regroupAll() {
+ return mIsInitiated && nativeRegroupAll();
+ }
+
+
+ public boolean regroup(long mediaId) {
+ return mIsInitiated && mediaId > 0 && nativeRegroup(mediaId);
+ }
+
@WorkerThread
public Album[] getAlbums() {
@@ -579,6 +589,10 @@ public class MedialibraryImpl extends Medialibrary {
private native VideoGroup nativeCreateGroupByName(String name);
private native VideoGroup nativeCreateGroup(long[] ids);
+
+ private native boolean nativeRegroupAll();
+
+ private native boolean nativeRegroup(long mediaId);
private native Album[] nativeGetAlbums(int sort, boolean desc);
private native Album[] nativeGetPagedAlbums(int sort, boolean desc, int nbItems, int offset);
private native int nativeGetAlbumsCount();
diff --git a/medialibrary/src/org/videolan/medialibrary/interfaces/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/interfaces/Medialibrary.java
index d07ebfe71..5435d07ba 100644
--- a/medialibrary/src/org/videolan/medialibrary/interfaces/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/interfaces/Medialibrary.java
@@ -718,6 +718,10 @@ abstract public class Medialibrary {
abstract public VideoGroup createVideoGroup(String name);
abstract public VideoGroup createVideoGroup(long[] ids);
+
+ abstract public boolean regroupAll();
+
+ abstract public boolean regroup(long mediaId);
abstract public Album[] getAlbums();
abstract public Album[] getAlbums(int sort, boolean desc);
abstract public Album[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset);
diff --git a/medialibrary/src/org/videolan/medialibrary/stubs/StubMedialibrary.java b/medialibrary/src/org/videolan/medialibrary/stubs/StubMedialibrary.java
index 0ffc172bd..fab093e9b 100644
--- a/medialibrary/src/org/videolan/medialibrary/stubs/StubMedialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/stubs/StubMedialibrary.java
@@ -158,6 +158,16 @@ public class StubMedialibrary extends Medialibrary {
return null;
}
+ @Override
+ public boolean regroupAll() {
+ return false;
+ }
+
+ @Override
+ public boolean regroup(long mediaId) {
+ return false;
+ }
+
public Album[] getAlbums() {
return getAlbums(SORT_DEFAULT, false);
}
More information about the Android
mailing list