[Android] Implement the new seen param for groups and display it

Nicolas Pomepuy git at videolan.org
Fri Jan 7 11:53:56 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Nov 17 16:06:27 2021 +0100| [ea383730f6aae4ab98f2413e280904ba88db888d] | committer: Nicolas Pomepuy

Implement the new seen param for groups and display it

Fixes #2029

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

 .../src/org/videolan/vlc/gui/video/VideoListAdapter.kt            | 3 ++-
 medialibrary/jni/medialibrary.cpp                                 | 2 +-
 medialibrary/jni/utils.cpp                                        | 2 +-
 .../org/videolan/medialibrary/interfaces/media/VideoGroup.java    | 8 +++++++-
 .../src/org/videolan/medialibrary/media/VideoGroupImpl.java       | 4 ++--
 .../src/org/videolan/medialibrary/stubs/StubVideoGroup.java       | 4 ++--
 6 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
index d22ac31ea..969e5a7b4 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.kt
@@ -149,7 +149,8 @@ class VideoListAdapter(private var isSeenMediaMarkerVisible: Boolean
                 holder.binding.setVariable(BR.time, if (count < 2) null else if (item.presentCount == item.mediaCount()) holder.itemView.context.resources.getQuantityString(R.plurals.videos_quantity, count, count) else item.getPresenceDescription())
                 holder.title.text = item.title
                 if (!isListMode) holder.binding.setVariable(BR.resolution, null)
-                holder.binding.setVariable(BR.seen, 0L)
+                val seen = if (item.presentSeen == item.presentCount) 1L else 0L
+                holder.binding.setVariable(BR.seen, seen)
                 holder.binding.setVariable(BR.max, 0)
                 holder.binding.setVariable(BR.isNetwork, item.isNetwork)
                 holder.binding.setVariable(BR.isPresent, item.presentCount > 0)
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index 061ec8f6c..04ecc34a8 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -2334,7 +2334,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
     GET_ID(GetMethodID,
            ml_fields.VideoGroup.initID,
            ml_fields.VideoGroup.clazz,
-           "<init>", "(JLjava/lang/String;II)V");
+           "<init>", "(JLjava/lang/String;III)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 4d4c5be8c..4743712ec 100644
--- a/medialibrary/jni/utils.cpp
+++ b/medialibrary/jni/utils.cpp
@@ -146,7 +146,7 @@ convertVideoGroupObject(JNIEnv* env, fields *fields, medialibrary::MediaGroupPtr
 {
     auto name = vlcNewStringUTF(env, videogroupPtr->name().c_str());
     return utils::jni::object{ env, env->NewObject(fields->VideoGroup.clazz, fields->VideoGroup.initID,
-                          (jlong) videogroupPtr->id(), name.get(), (jint)videogroupPtr->nbVideo(), (jint)videogroupPtr->nbPresentVideo())
+                          (jlong) videogroupPtr->id(), name.get(), (jint)videogroupPtr->nbVideo(), (jint)videogroupPtr->nbPresentVideo(), (jint)videogroupPtr->nbPresentSeen())
     };
 }
 
diff --git a/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java b/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java
index f439c3c1b..c4114b874 100644
--- a/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java
+++ b/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java
@@ -14,12 +14,14 @@ public abstract class VideoGroup extends MediaLibraryItem {
 
     public int mCount;
     public int mPresentCount;
+    public int mPresentSeen;
     public boolean isNetwork = false;
 
-    public VideoGroup(long id, String name, int count, int presentCount) {
+    public VideoGroup(long id, String name, int count, int presentCount, int presentSeen) {
         super(id, name);
         mCount = count;
         mPresentCount = presentCount;
+        mPresentSeen = presentSeen;
     }
 
     abstract public MediaWrapper[] media(int sort, boolean desc, boolean includeMissing, int nbItems, int offset);
@@ -45,6 +47,10 @@ public abstract class VideoGroup extends MediaLibraryItem {
         return mPresentCount;
     }
 
+    public int getPresentSeen() {
+        return mPresentSeen;
+    }
+
     @Override
     public MediaWrapper[] getTracks() {
         return new MediaWrapper[0];
diff --git a/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java b/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java
index 682e67f79..609483c4a 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, int presentCount) {
-        super(id, name, count, presentCount);
+    VideoGroupImpl(long id, String name, int count, int presentCount, int presentSeen) {
+        super(id, name, count, presentCount, presentSeen);
     }
 
     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 b34e793fc..90f086a31 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, int presentCount) {
-        super(0L, name, count, presentCount);
+    public StubVideoGroup(String name, int count, int presentCount, int presentSeen) {
+        super(0L, name, count, presentCount, presentSeen);
     }
 
     public StubVideoGroup(Parcel in) {



More information about the Android mailing list