[Android] Fix video group item not updated when changing name or track count

Nicolas Pomepuy git at videolan.org
Tue May 26 10:19:51 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon May 25 09:53:17 2020 +0200| [a7f9d41e9a776f3cb670ad40547e7d8c35645981] | committer: Nicolas Pomepuy

Fix video group item not updated when changing name or track count

Fixes #1360

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

 .../src/main/java/org/videolan/resources/Constants.kt         |  1 +
 .../src/org/videolan/vlc/gui/video/VideoListAdapter.kt        | 11 +++++++----
 .../videolan/medialibrary/interfaces/media/VideoGroup.java    |  2 +-
 .../src/org/videolan/medialibrary/media/VideoGroupImpl.java   |  4 +---
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/application/resources/src/main/java/org/videolan/resources/Constants.kt b/application/resources/src/main/java/org/videolan/resources/Constants.kt
index d0108e2e5..4918e50e3 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -150,6 +150,7 @@ const val UPDATE_TIME = 2
 const val UPDATE_SEEN = 3
 const val UPDATE_DESCRIPTION = 4
 const val UPDATE_PAYLOAD = 5
+const val UPDATE_VIDEO_GROUP = 6
 
 const val KEY_URI = "uri"
 const val SELECTED_ITEM = "selected"
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 bff0e56f3..3b4c007ee 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
@@ -46,10 +46,7 @@ import org.videolan.medialibrary.interfaces.media.Folder
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.interfaces.media.VideoGroup
 import org.videolan.medialibrary.media.MediaLibraryItem
-import org.videolan.resources.UPDATE_SEEN
-import org.videolan.resources.UPDATE_SELECTION
-import org.videolan.resources.UPDATE_THUMB
-import org.videolan.resources.UPDATE_TIME
+import org.videolan.resources.*
 import org.videolan.tools.MultiSelectAdapter
 import org.videolan.tools.MultiSelectHelper
 import org.videolan.tools.safeOffer
@@ -122,6 +119,7 @@ class VideoListAdapter(private var isSeenMediaMarkerVisible: Boolean
                     UPDATE_THUMB -> loadImage(holder.overlay, media)
                     UPDATE_TIME, UPDATE_SEEN -> fillView(holder, media as MediaWrapper)
                     UPDATE_SELECTION -> holder.selectView(multiSelectHelper.isSelected(position))
+                    UPDATE_VIDEO_GROUP -> fillView(holder, media!!)
                 }
             }
         }
@@ -252,11 +250,16 @@ class VideoListAdapter(private var isSeenMediaMarkerVisible: Boolean
                         && TextUtils.equals(oldItem.artworkMrl, newItem.artworkMrl)
                         && oldItem.seen == newItem.seen)
             } //else if (oldItem is FolderImpl && newItem is FolderImpl) return oldItem === newItem || (oldItem.title == newItem.title && oldItem.artworkMrl == newItem.artworkMrl)
+            else if (oldItem is VideoGroup && newItem is VideoGroup) {
+                oldItem === newItem || (oldItem.title == newItem.title
+                        && oldItem.tracksCount == newItem.tracksCount)
+            }
             else oldItem.itemType == MediaLibraryItem.TYPE_FOLDER || oldItem.itemType == MediaLibraryItem.TYPE_VIDEO_GROUP
         }
 
         override fun getChangePayload(oldItem: MediaLibraryItem, newItem: MediaLibraryItem) = when {
             (oldItem is MediaWrapper && newItem is MediaWrapper) && oldItem.displayTime != newItem.displayTime -> UPDATE_TIME
+            (oldItem is VideoGroup && newItem is VideoGroup) -> UPDATE_VIDEO_GROUP
             !TextUtils.equals(oldItem.artworkMrl, newItem.artworkMrl) -> UPDATE_THUMB
             else -> UPDATE_SEEN
         }
diff --git a/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java b/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java
index 781e42ecf..6252cc59a 100644
--- a/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java
+++ b/medialibrary/src/org/videolan/medialibrary/interfaces/media/VideoGroup.java
@@ -25,7 +25,7 @@ public abstract class VideoGroup extends MediaLibraryItem {
     abstract public boolean add(long mediaId);
     abstract public boolean remove(long mediaId);
     @Nullable abstract public String getName();
-    abstract public boolean rename(String name);
+    abstract public boolean  rename(String name);
     abstract public boolean userInteracted();
     abstract public long duration();
     abstract public boolean destroy();
diff --git a/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java b/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java
index 785141d32..7ec801074 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/VideoGroupImpl.java
@@ -65,9 +65,7 @@ public class VideoGroupImpl extends VideoGroup {
     @Override
     public boolean rename(String name) {
         final Medialibrary ml = Medialibrary.getInstance();
-        boolean newNameSet = ml.isInitiated() && nativeGroupRename(ml, mId, name);
-        if (newNameSet) setTitle(name);
-        return newNameSet;
+        return  ml.isInitiated() && nativeGroupRename(ml, mId, name);
     }
 
     @Override



More information about the Android mailing list