Commit ad20e368 authored by Geoffrey Métais's avatar Geoffrey Métais

Add tracksCount info to Playlist

parent f662492f
......@@ -925,7 +925,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
GET_ID(GetMethodID,
ml_fields.Playlist.initID,
ml_fields.Playlist.clazz,
"<init>", "(JLjava/lang/String;)V");
"<init>", "(JLjava/lang/String;I)V");
GET_CLASS(ml_fields.MediaWrapper.clazz,
......
......@@ -139,7 +139,7 @@ convertPlaylistObject(JNIEnv* env, fields *fields, medialibrary::PlaylistPtr con
{
jstring name = env->NewStringUTF(playlistPtr->name().c_str());
jobject item = env->NewObject(fields->Playlist.clazz, fields->Playlist.initID,
(jlong) playlistPtr->id(), name);
(jlong) playlistPtr->id(), name, (jint)playlistPtr->media().size());
env->DeleteLocalRef(name);
return item;
}
......
......@@ -9,18 +9,21 @@ import java.util.List;
public class Playlist extends MediaLibraryItem {
protected Playlist(long id, String name) {
super(id, name);
}
private int mTracksCount;
protected Playlist(Parcel in) {
super(in);
protected Playlist(long id, String name, int trackCount) {
super(id, name);
mTracksCount = trackCount;
}
public MediaWrapper[] getTracks(Medialibrary ml) {
return ml != null && ml.isInitiated() ? nativeGetTracksFromPlaylist(ml, mId) : Medialibrary.EMPTY_COLLECTION;
}
public int getTracksCount() {
return mTracksCount;
}
@Override
public int getItemType() {
return TYPE_PLAYLIST;
......@@ -70,6 +73,17 @@ public class Playlist extends MediaLibraryItem {
}
};
@Override
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(mTracksCount);
}
private Playlist(Parcel in) {
super(in);
this.mTracksCount = in.readInt();
}
private native MediaWrapper[] nativeGetTracksFromPlaylist(Medialibrary ml, long id);
private native boolean nativePlaylistAppend(Medialibrary ml, long id, long mediaId);
private native boolean nativePlaylistAppendGroup(Medialibrary ml, long id, long[] mediaIds);
......
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