Commit 4b0d0190 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Medialibrary: Match API update

parent 27969970
......@@ -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))
{
......
......@@ -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 );
......
......@@ -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,
......
......@@ -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();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment