[Android] Implement isPresent for media groups

Nicolas Pomepuy git at videolan.org
Thu Jun 10 06:17:25 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Feb  1 16:13:46 2021 +0100| [b30e0f9a35810ca681a068cd3a6be2cc69217897] | committer: Nicolas Pomepuy

Implement isPresent for media groups

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

 medialibrary/jni/medialibrary.cpp                       |  2 +-
 medialibrary/jni/utils.cpp                              |  2 +-
 .../medialibrary/interfaces/media/VideoGroup.java       | 17 ++++++++++++++++-
 .../org/videolan/medialibrary/media/VideoGroupImpl.java |  4 ++--
 .../org/videolan/medialibrary/stubs/StubVideoGroup.java |  4 ++--
 5 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 132c5586e..dc3cd8349 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -2348,7 +2348,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
     GET_ID(GetMethodID,
            ml_fields.VideoGroup.initID,
            ml_fields.VideoGroup.clazz,
-           "<init>", "(JLjava/lang/String;I)V");
+           "<init>", "(JLjava/lang/String;II)V");
 
     GET_CLASS(ml_fields.Bookmark.clazz, "org/videolan/medialibrary/media/BookmarkImpl", true);
     if (env->RegisterNatives(ml_fields.Bookmark.clazz, bookmark_methods, sizeof(bookmark_methods) / sizeof(bookmark_methods[0])) < 0) {
diff --git a/medialibrary/jni/utils.cpp b/medialibrary/jni/utils.cpp
index f54a38176..bfd8839ac 100644
--- a/medialibrary/jni/utils.cpp
+++ b/medialibrary/jni/utils.cpp
@@ -163,7 +163,7 @@ convertVideoGroupObject(JNIEnv* env, fields *fields, medialibrary::MediaGroupPtr
 {
     jstring name = env->NewStringUTF(videogroupPtr->name().c_str());
     jobject item = env->NewObject(fields->VideoGroup.clazz, fields->VideoGroup.initID,
-                          (jlong) videogroupPtr->id(), name, (jint)videogroupPtr->nbVideo());
+                          (jlong) videogroupPtr->id(), name, (jint)videogroupPtr->nbVideo(), (jint)videogroupPtr->nbPresentVideo());
     env->DeleteLocalRef(name);
     return item;
 }
diff --git a/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java b/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java
index ee9870718..f439c3c1b 100644
--- a/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java
+++ b/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java
@@ -13,10 +13,13 @@ import org.videolan.medialibrary.media.MediaLibraryItem;
 public abstract class VideoGroup extends MediaLibraryItem {
 
     public int mCount;
+    public int mPresentCount;
+    public boolean isNetwork = false;
 
-    public VideoGroup(long id, String name, int count) {
+    public VideoGroup(long id, String name, int count, int presentCount) {
         super(id, name);
         mCount = count;
+        mPresentCount = presentCount;
     }
 
     abstract public MediaWrapper[] media(int sort, boolean desc, boolean includeMissing, int nbItems, int offset);
@@ -38,6 +41,10 @@ public abstract class VideoGroup extends MediaLibraryItem {
         return mCount;
     }
 
+    public int getPresentCount() {
+        return mPresentCount;
+    }
+
     @Override
     public MediaWrapper[] getTracks() {
         return new MediaWrapper[0];
@@ -53,6 +60,14 @@ public abstract class VideoGroup extends MediaLibraryItem {
         return TYPE_VIDEO_GROUP;
     }
 
+    public boolean isNetwork() {
+        return isNetwork;
+    }
+
+    public void setNetwork(boolean network) {
+        isNetwork = network;
+    }
+
     @Override
     public void writeToParcel(Parcel parcel, int i) {
         super.writeToParcel(parcel, i);
diff --git a/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java b/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java
index b1f29839c..682e67f79 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java
@@ -13,8 +13,8 @@ import org.videolan.medialibrary.interfaces.media.VideoGroup;
 public class VideoGroupImpl extends VideoGroup {
 
     @SuppressWarnings("unused") /* Used from JNI */
-    VideoGroupImpl(long id, String name, int count) {
-        super(id, name, count);
+    VideoGroupImpl(long id, String name, int count, int presentCount) {
+        super(id, name, count, presentCount);
     }
 
     public VideoGroupImpl(Parcel in) {
diff --git a/medialibrary/src/org/videolan/medialibrary/stubs/StubVideoGroup.java b/medialibrary/src/org/videolan/medialibrary/stubs/StubVideoGroup.java
index 28e1f1b76..b34e793fc 100644
--- a/medialibrary/src/org/videolan/medialibrary/stubs/StubVideoGroup.java
+++ b/medialibrary/src/org/videolan/medialibrary/stubs/StubVideoGroup.java
@@ -6,8 +6,8 @@ import org.videolan.medialibrary.interfaces.media.MediaWrapper;
 import org.videolan.medialibrary.interfaces.media.VideoGroup;
 
 public class StubVideoGroup extends VideoGroup {
-    public StubVideoGroup(String name, int count) {
-        super(0L, name, count);
+    public StubVideoGroup(String name, int count, int presentCount) {
+        super(0L, name, count, presentCount);
     }
 
     public StubVideoGroup(Parcel in) {



More information about the Android mailing list