[Android] Medialibrary: Match API update

Geoffrey Métais git at videolan.org
Tue Sep 24 16:29:35 CEST 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Sep 24 12:18:16 2019 +0200| [a8d18d5cb8eea09878b1cf8849c4774249ad9848] | committer: Geoffrey Métais

Medialibrary: Match API update

(cherry picked from commit 4b0d01904fdbe7e92ad907ea9391e3d32cb5df20)

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

 medialibrary/jni/AndroidMediaLibrary.cpp           | 43 ++++------------------
 medialibrary/jni/AndroidMediaLibrary.h             | 10 ++---
 medialibrary/jni/medialibrary.cpp                  |  2 +-
 .../interfaces/AbstractMedialibrary.java           |  2 +-
 4 files changed, 14 insertions(+), 43 deletions(-)

diff --git a/medialibrary/jni/AndroidMediaLibrary.cpp b/medialibrary/jni/AndroidMediaLibrary.cpp
index 28c4b272e..f64038770 100644
--- a/medialibrary/jni/AndroidMediaLibrary.cpp
+++ b/medialibrary/jni/AndroidMediaLibrary.cpp
@@ -562,45 +562,16 @@ AndroidMediaLibrary::onMediaAdded( std::vector<medialibrary::MediaPtr> mediaList
     }
 }
 
-void AndroidMediaLibrary::onMediaModified( std::vector<medialibrary::MediaPtr> mediaList )
+void AndroidMediaLibrary::onMediaModified( std::vector<int64_t> mediaIds )
 {
     if (m_mediaUpdatedType & FLAG_MEDIA_UPDATED_AUDIO || m_mediaUpdatedType & FLAG_MEDIA_UPDATED_VIDEO
             || m_mediaUpdatedType & FLAG_MEDIA_UPDATED_AUDIO_EMPTY) {
         JNIEnv *env = getEnv();
         if (env == NULL)
             return;
-        jobjectArray mediaRefs, results;
-        int index;
-        if ((m_mediaUpdatedType & (FLAG_MEDIA_UPDATED_AUDIO|FLAG_MEDIA_UPDATED_VIDEO)) == 0)
-        {
-            index = 0;
-            mediaRefs = (jobjectArray) env->NewObjectArray(0, p_fields->MediaWrapper.clazz, NULL);
-        } else
-        {
-            mediaRefs = (jobjectArray) env->NewObjectArray(mediaList.size(), p_fields->MediaWrapper.clazz, NULL);
-            index = -1;
-            jobject item;
-            for (medialibrary::MediaPtr const& media : mediaList) {
-                medialibrary::IMedia::Type type = media->type();
-                if ((type == medialibrary::IMedia::Type::Audio && m_mediaUpdatedType & FLAG_MEDIA_UPDATED_AUDIO) ||
-                        (type == medialibrary::IMedia::Type::Video && m_mediaUpdatedType & FLAG_MEDIA_UPDATED_VIDEO))
-                    item = mediaToMediaWrapper(env, p_fields, media);
-                else
-                    item = nullptr;
-                env->SetObjectArrayElement(mediaRefs, ++index, item);
-                if (item != nullptr)
-                    env->DeleteLocalRef(item);
-            }
-        }
-        if (index > -1)
+        if (weak_thiz)
         {
-            results = filteredArray(env, mediaRefs, p_fields->MediaWrapper.clazz, -1);
-            if (weak_thiz)
-            {
-                env->CallVoidMethod(weak_thiz, p_fields->MediaLibrary.onMediaUpdatedId, results);
-                env->DeleteLocalRef(results);
-            } else
-                env->DeleteLocalRef(mediaRefs);
+            env->CallVoidMethod(weak_thiz, p_fields->MediaLibrary.onMediaUpdatedId);
         }
     }
 }
@@ -624,7 +595,7 @@ void AndroidMediaLibrary::onArtistsAdded( std::vector<medialibrary::ArtistPtr> a
     }
 }
 
-void AndroidMediaLibrary::onArtistsModified( std::vector<medialibrary::ArtistPtr> artist )
+void AndroidMediaLibrary::onArtistsModified( std::vector<int64_t>  artistsIds )
 {
     if (m_mediaUpdatedType & (FLAG_MEDIA_UPDATED_AUDIO|FLAG_MEDIA_UPDATED_AUDIO_EMPTY))
     {
@@ -662,7 +633,7 @@ void AndroidMediaLibrary::onAlbumsAdded( std::vector<medialibrary::AlbumPtr> alb
     }
 }
 
-void AndroidMediaLibrary::onAlbumsModified( std::vector<medialibrary::AlbumPtr> albums )
+void AndroidMediaLibrary::onAlbumsModified( std::vector<int64_t> albums )
 {
     if (m_mediaUpdatedType & (FLAG_MEDIA_UPDATED_AUDIO|FLAG_MEDIA_UPDATED_AUDIO_EMPTY))
     {
@@ -689,7 +660,7 @@ void AndroidMediaLibrary::onPlaylistsAdded( std::vector<medialibrary::PlaylistPt
 
 }
 
-void AndroidMediaLibrary::onPlaylistsModified( std::vector<medialibrary::PlaylistPtr> playlist )
+void AndroidMediaLibrary::onPlaylistsModified( std::vector<int64_t> playlist )
 {
     if (m_mediaUpdatedType & (FLAG_MEDIA_UPDATED_AUDIO|FLAG_MEDIA_UPDATED_AUDIO_EMPTY))
     {
@@ -728,7 +699,7 @@ void AndroidMediaLibrary::onGenresAdded( std::vector<medialibrary::GenrePtr> )
     }
 }
 
-void AndroidMediaLibrary::onGenresModified( std::vector<medialibrary::GenrePtr> )
+void AndroidMediaLibrary::onGenresModified( std::vector<int64_t> )
 {
     if (m_mediaUpdatedType & (FLAG_MEDIA_UPDATED_AUDIO|FLAG_MEDIA_UPDATED_AUDIO_EMPTY))
     {
diff --git a/medialibrary/jni/AndroidMediaLibrary.h b/medialibrary/jni/AndroidMediaLibrary.h
index 0847d7d82..84844a45b 100644
--- a/medialibrary/jni/AndroidMediaLibrary.h
+++ b/medialibrary/jni/AndroidMediaLibrary.h
@@ -110,23 +110,23 @@ public:
                            uint32_t desiredHeight, float position );
 
     void onMediaAdded( std::vector<medialibrary::MediaPtr> media );
-    void onMediaModified( std::vector<medialibrary::MediaPtr> media ) ;
+    void onMediaModified( std::vector<int64_t> media ) ;
     void onMediaDeleted( std::vector<int64_t> ids ) ;
 
     void onArtistsAdded( std::vector<medialibrary::ArtistPtr> artists ) ;
-    void onArtistsModified( std::vector<medialibrary::ArtistPtr> artist );
+    void onArtistsModified( std::vector<int64_t> artist );
     void onArtistsDeleted( std::vector<int64_t> ids );
 
     void onAlbumsAdded( std::vector<medialibrary::AlbumPtr> albums );
-    void onAlbumsModified( std::vector<medialibrary::AlbumPtr> albums );
+    void onAlbumsModified( std::vector<int64_t> albums );
     void onAlbumsDeleted( std::vector<int64_t> ids );
 
     void onPlaylistsAdded( std::vector<medialibrary::PlaylistPtr> playlists );
-    void onPlaylistsModified( std::vector<medialibrary::PlaylistPtr> playlist );
+    void onPlaylistsModified( std::vector<int64_t> playlist );
     void onPlaylistsDeleted( std::vector<int64_t> ids );
 
     void onGenresAdded( std::vector<medialibrary::GenrePtr> );
-    void onGenresModified( std::vector<medialibrary::GenrePtr> );
+    void onGenresModified( std::vector<int64_t> );
     void onGenresDeleted( std::vector<int64_t> );
 
     void onDiscoveryStarted( const std::string& entryPoint );
diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index be13b0032..dadf17a01 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -2044,7 +2044,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
     GET_ID(GetMethodID,
            ml_fields.MediaLibrary.onMediaUpdatedId,
            ml_fields.MediaLibrary.clazz,
-           "onMediaUpdated", "([Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;)V");
+           "onMediaUpdated", "()V");
     GET_ID(GetMethodID,
            ml_fields.MediaLibrary.onMediaDeletedId,
            ml_fields.MediaLibrary.clazz,
diff --git a/medialibrary/src/org/videolan/medialibrary/interfaces/AbstractMedialibrary.java b/medialibrary/src/org/videolan/medialibrary/interfaces/AbstractMedialibrary.java
index cbeae4fb8..420e2ac3e 100644
--- a/medialibrary/src/org/videolan/medialibrary/interfaces/AbstractMedialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/interfaces/AbstractMedialibrary.java
@@ -233,7 +233,7 @@ abstract public class AbstractMedialibrary {
     }
 
     @SuppressWarnings("unused")
-    public void onMediaUpdated(AbstractMediaWrapper[] mediaList) {
+    public void onMediaUpdated() {
         synchronized (mMediaCbs) {
             for (MediaCb cb : mMediaCbs) cb.onMediaModified();
         }



More information about the Android mailing list