Commit d2519832 authored by Duncan McNAMARA's avatar Duncan McNAMARA
Browse files

Medialibrary: move Album to AAlbum

parent fa5fec85
......@@ -1756,8 +1756,8 @@ static JNINativeMethod methods[] = {
{"nativeGetSearchVideoCount", "(Ljava/lang/String;)I", (void*)getSearchVideoCount },
{"nativeGetSearchAudioCount", "(Ljava/lang/String;)I", (void*)getSearchAudioCount },
{"nativeGetSearchMediaCount", "(Ljava/lang/String;)I", (void*)getSearchMediaCount },
{"nativeSearchAlbum", "(Ljava/lang/String;)[Lorg/videolan/medialibrary/media/Album;", (void*)searchAlbum },
{"nativeSearchPagedAlbum", "(Ljava/lang/String;IZII)[Lorg/videolan/medialibrary/media/Album;", (void*)searchPagedAlbum },
{"nativeSearchAlbum", "(Ljava/lang/String;)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)searchAlbum },
{"nativeSearchPagedAlbum", "(Ljava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)searchPagedAlbum },
{"nativeGetAlbumSearchCount", "(Ljava/lang/String;)I", (void*)getAlbumSearchCount },
{"nativeSearchArtist", "(Ljava/lang/String;)[Lorg/videolan/medialibrary/interfaces/media/AArtist;", (void*)searchArtist },
{"nativeSearchPagedArtist", "(Ljava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/AArtist;", (void*)searchPagedArtist },
......@@ -1775,10 +1775,10 @@ static JNINativeMethod methods[] = {
{"nativeAddStream", "(Ljava/lang/String;Ljava/lang/String;)Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;", (void*)addStream },
{"nativeGetVideoCount", "()I", (void*)getVideoCount },
{"nativeGetAudioCount", "()I", (void*)getAudioCount },
{"nativeGetAlbums", "(IZ)[Lorg/videolan/medialibrary/media/Album;", (void*)getAlbums },
{"nativeGetPagedAlbums", "(IZII)[Lorg/videolan/medialibrary/media/Album;", (void*)getPagedAlbums },
{"nativeGetAlbums", "(IZ)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)getAlbums },
{"nativeGetPagedAlbums", "(IZII)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)getPagedAlbums },
{"nativeGetAlbumsCount", "()I", (void*)getAlbumsCount },
{"nativeGetAlbum", "(J)Lorg/videolan/medialibrary/media/Album;", (void*)getAlbum },
{"nativeGetAlbum", "(J)Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)getAlbum },
{"nativeGetArtists", "(ZIZ)[Lorg/videolan/medialibrary/interfaces/media/AArtist;", (void*)getArtists },
{"nativeGetPagedArtists", "(ZIZII)[Lorg/videolan/medialibrary/interfaces/media/AArtist;", (void*)getPagedArtists },
{"nativeGetArtistsCount", "(Z)I", (void*)getArtistsCount },
......@@ -1826,11 +1826,11 @@ static JNINativeMethod album_methods[] = {
static JNINativeMethod artist_methods[] = {
{"nativeGetMedia", "(Lorg/videolan/medialibrary/Medialibrary;JIZ)[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;", (void*)getMediaFromArtist },
{"nativeGetAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JIZ)[Lorg/videolan/medialibrary/media/Album;", (void*)getAlbumsFromArtist },
{"nativeGetAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JIZ)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)getAlbumsFromArtist },
{"nativeGetPagedMedia", "(Lorg/videolan/medialibrary/Medialibrary;JIZII)[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;", (void*)getPagedMediaFromArtist },
{"nativeGetPagedAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JIZII)[Lorg/videolan/medialibrary/media/Album;", (void*)getPagedAlbumsFromArtist },
{"nativeGetPagedAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JIZII)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)getPagedAlbumsFromArtist },
{"nativeSearch", "(Lorg/videolan/medialibrary/Medialibrary;JLjava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;", (void*)searchFromArtist },
{"nativeSearchAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JLjava/lang/String;IZII)[Lorg/videolan/medialibrary/media/Album;", (void*)searchAlbumsFromArtist },
{"nativeSearchAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JLjava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)searchAlbumsFromArtist },
{"nativeGetTracksCount", "(Lorg/videolan/medialibrary/Medialibrary;J)I", (void*)getArtistTracksCount },
{"nativeGetAlbumsCount", "(Lorg/videolan/medialibrary/Medialibrary;J)I", (void*)getArtistAlbumsCount },
{"nativeGetSearchCount", "(Lorg/videolan/medialibrary/Medialibrary;JLjava/lang/String;)I", (void*)getSearchFromArtistCount },
......@@ -1839,13 +1839,13 @@ static JNINativeMethod artist_methods[] = {
static JNINativeMethod genre_methods[] = {
{"nativeGetTracks", "(Lorg/videolan/medialibrary/Medialibrary;JIZ)[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;", (void*)getMediaFromGenre },
{"nativeGetAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JIZ)[Lorg/videolan/medialibrary/media/Album;", (void*)getAlbumsFromGenre },
{"nativeGetAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JIZ)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)getAlbumsFromGenre },
{"nativeGetArtists", "(Lorg/videolan/medialibrary/Medialibrary;JIZ)[Lorg/videolan/medialibrary/interfaces/media/AArtist;", (void*)getArtistsFromGenre },
{"nativeGetPagedTracks", "(Lorg/videolan/medialibrary/Medialibrary;JIZII)[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;", (void*)getPagedMediaFromGenre },
{"nativeGetPagedAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JIZII)[Lorg/videolan/medialibrary/media/Album;", (void*)getPagedAlbumsFromGenre },
{"nativeGetPagedAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JIZII)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)getPagedAlbumsFromGenre },
{"nativeGetPagedArtists", "(Lorg/videolan/medialibrary/Medialibrary;JIZII)[Lorg/videolan/medialibrary/interfaces/media/AArtist;", (void*)getPagedArtistsFromGenre },
{"nativeSearch", "(Lorg/videolan/medialibrary/Medialibrary;JLjava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;", (void*)searchMediaFromGenre },
{"nativeSearchAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JLjava/lang/String;IZII)[Lorg/videolan/medialibrary/media/Album;", (void*)searchAlbumsFromGenre },
{"nativeSearchAlbums", "(Lorg/videolan/medialibrary/Medialibrary;JLjava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/AAlbum;", (void*)searchAlbumsFromGenre },
{"nativeGetTracksCount", "(Lorg/videolan/medialibrary/Medialibrary;J)I", (void*)getGenreTracksCount },
{"nativeGetAlbumsCount", "(Lorg/videolan/medialibrary/Medialibrary;J)I", (void*)getGenreAlbumsCount },
{"nativeGetArtistsCount", "(Lorg/videolan/medialibrary/Medialibrary;J)I", (void*)getGenreArtistsCount },
......@@ -2008,7 +2008,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
GET_ID(GetMethodID,
ml_fields.SearchAggregate.initID,
ml_fields.SearchAggregate.clazz,
"<init>", "([Lorg/videolan/medialibrary/media/Album;[Lorg/videolan/medialibrary/interfaces/media/AArtist;[Lorg/videolan/medialibrary/interfaces/media/AGenre;[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;[Lorg/videolan/medialibrary/media/Playlist;)V");
"<init>", "([Lorg/videolan/medialibrary/interfaces/media/AAlbum;[Lorg/videolan/medialibrary/interfaces/media/AArtist;[Lorg/videolan/medialibrary/interfaces/media/AGenre;[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;[Lorg/videolan/medialibrary/interfaces/media/AMediaWrapper;[Lorg/videolan/medialibrary/media/Playlist;)V");
GET_CLASS(ml_fields.Folder.clazz, "org/videolan/medialibrary/media/Folder", true);
......
......@@ -33,10 +33,10 @@ import android.util.Log;
import org.videolan.libvlc.LibVLC;
import org.videolan.medialibrary.interfaces.DevicesDiscoveryCb;
import org.videolan.medialibrary.interfaces.EntryPointsEventsCb;
import org.videolan.medialibrary.interfaces.media.AAlbum;
import org.videolan.medialibrary.interfaces.media.AArtist;
import org.videolan.medialibrary.interfaces.media.AGenre;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import org.videolan.medialibrary.media.Album;
import org.videolan.medialibrary.media.Folder;
import org.videolan.medialibrary.media.Playlist;
import org.videolan.medialibrary.media.SearchAggregate;
......@@ -268,19 +268,19 @@ public class Medialibrary {
@WorkerThread
public Album[] getAlbums() {
public AAlbum[] getAlbums() {
return getAlbums(Medialibrary.SORT_DEFAULT, false);
}
@WorkerThread
public Album[] getAlbums(int sort, boolean desc) {
return mIsInitiated ? nativeGetAlbums(sort, desc) : new Album[0];
public AAlbum[] getAlbums(int sort, boolean desc) {
return mIsInitiated ? nativeGetAlbums(sort, desc) : new AAlbum[0];
}
@NonNull
@WorkerThread
public Album[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset) {
return mIsInitiated ? nativeGetPagedAlbums(sort, desc, nbItems, offset) : new Album[0];
public AAlbum[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset) {
return mIsInitiated ? nativeGetPagedAlbums(sort, desc, nbItems, offset) : new AAlbum[0];
}
public int getAlbumsCount() {
......@@ -292,7 +292,7 @@ public class Medialibrary {
}
@WorkerThread
public Album getAlbum(long albumId) {
public AAlbum getAlbum(long albumId) {
return mIsInitiated ? nativeGetAlbum(albumId) : null;
}
......@@ -856,11 +856,11 @@ public class Medialibrary {
return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchPagedArtist(query, sort, desc, nbItems, offset) : new AArtist[0];
}
public Album[] searchAlbum(String query, int sort, boolean desc, int nbItems, int offset) {
public AAlbum[] searchAlbum(String query, int sort, boolean desc, int nbItems, int offset) {
return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchPagedAlbum(query, sort, desc, nbItems, offset) : null;
}
public Album[] searchAlbum(String query) {
public AAlbum[] searchAlbum(String query) {
return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchAlbum(query) : null;
}
......@@ -1000,10 +1000,10 @@ public class Medialibrary {
private native AMediaWrapper[] nativeGetRecentAudio();
private native int nativeGetVideoCount();
private native int nativeGetAudioCount();
private native Album[] nativeGetAlbums(int sort, boolean desc);
private native Album[] nativeGetPagedAlbums(int sort, boolean desc, int nbItems, int offset);
private native AAlbum[] nativeGetAlbums(int sort, boolean desc);
private native AAlbum[] nativeGetPagedAlbums(int sort, boolean desc, int nbItems, int offset);
private native int nativeGetAlbumsCount();
private native Album nativeGetAlbum(long albumtId);
private native AAlbum nativeGetAlbum(long albumtId);
private native AArtist[] nativeGetArtists(boolean all, int sort, boolean desc);
private native AArtist[] nativeGetPagedArtists(boolean all, int sort, boolean desc, int nbItems, int offset);
private native int nativeGetArtistsCount(boolean all);
......@@ -1039,8 +1039,8 @@ public class Medialibrary {
private native AArtist[] nativeSearchArtist(String query);
private native AArtist[] nativeSearchPagedArtist(String query, int sort, boolean desc, int nbItems, int offset);
private native int nativeGetArtistsSearchCount(String query);
private native Album[] nativeSearchAlbum(String query);
private native Album[] nativeSearchPagedAlbum(String query, int sort, boolean desc, int nbItems, int offset);
private native AAlbum[] nativeSearchAlbum(String query);
private native AAlbum[] nativeSearchPagedAlbum(String query, int sort, boolean desc, int nbItems, int offset);
private native int nativeGetAlbumSearchCount(String query);
private native AGenre[] nativeSearchGenre(String query);
private native AGenre[] nativeSearchPagedGenre(String query, int sort, boolean desc, int nbItems, int offset);
......
......@@ -5,16 +5,18 @@ import android.net.Uri;
import android.os.Parcel;
import org.videolan.libvlc.Media;
import org.videolan.medialibrary.interfaces.media.AAlbum;
import org.videolan.medialibrary.interfaces.media.AArtist;
import org.videolan.medialibrary.interfaces.media.AGenre;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
import org.videolan.medialibrary.media.Album;
import org.videolan.medialibrary.media.Artist;
import org.videolan.medialibrary.media.Genre;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.medialibrary.stubs.StubAlbum;
import org.videolan.medialibrary.stubs.StubArtist;
import org.videolan.medialibrary.stubs.StubGenre;
import org.videolan.medialibrary.stubs.StubMediaWrapper;
import org.xml.sax.Locator;
public class ServiceLocator {
......@@ -127,4 +129,25 @@ public class ServiceLocator {
return new StubGenre(in);
}
}
//Album
public static AAlbum getAAlbum(long id, String title, int releaseYear, String artworkMrl,
String albumArtist, long albumArtistId, int nbTracks,
int duration) {
if (mMode == LocatorMode.VLC_ANDROID) {
return new Album(id, title, releaseYear, artworkMrl, albumArtist, albumArtistId,
nbTracks, duration);
} else {
return new StubAlbum(id, title, releaseYear, artworkMrl, albumArtist, albumArtistId,
nbTracks, duration);
}
}
public static AAlbum getAAlbum(Parcel in) {
if (mMode == LocatorMode.VLC_ANDROID) {
return new Album(in);
} else {
return new StubAlbum(in);
}
}
}
package org.videolan.medialibrary.interfaces.media;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import org.videolan.libvlc.util.VLCUtil;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.medialibrary.R;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.media.MediaLibraryItem;
public abstract class AAlbum extends MediaLibraryItem {
public static class SpecialRes {
public static String UNKNOWN_ALBUM = Medialibrary.getContext().getString(R.string.unknown_album);
}
protected int releaseYear;
protected String artworkMrl;
protected String albumArtist;
protected long albumArtistId;
protected int mTracksCount;
protected int duration;
public AAlbum(long id, String title, int releaseYear, String artworkMrl, String albumArtist, long albumArtistId, int nbTracks, int duration) {
super(id, title);
this.releaseYear = releaseYear;
this.artworkMrl = artworkMrl != null ? VLCUtil.UriFromMrl(artworkMrl).getPath() : null;
this.albumArtist = albumArtist != null ? albumArtist.trim(): null;
this.albumArtistId = albumArtistId;
this.mTracksCount = nbTracks;
this.duration = duration;
if (TextUtils.isEmpty(title)) mTitle = SpecialRes.UNKNOWN_ALBUM;
if (albumArtistId == 1L) {
this.albumArtist = AArtist.SpecialRes.UNKNOWN_ARTIST;
} else if (albumArtistId == 2L) {
this.albumArtist = AArtist.SpecialRes.VARIOUS_ARTISTS;
}
}
protected AAlbum(Parcel in) {
super(in);
this.releaseYear = in.readInt();
this.artworkMrl = in.readString();
this.albumArtist = in.readString();
this.albumArtistId = in.readLong();
this.mTracksCount = in.readInt();
this.duration = in.readInt();
}
abstract public int getRealTracksCount();
abstract public AMediaWrapper[] getTracks(int sort, boolean desc);
abstract public AMediaWrapper[] getPagedTracks(int sort, boolean desc, int nbItems, int offset);
abstract public AMediaWrapper[] searchTracks(String query, int sort, boolean desc, int nbItems, int offset);
abstract public int searchTracksCount(String query);
@Override
public long getId() {
return mId;
}
@Override
public String getDescription() {
return albumArtist;
}
public int getReleaseYear() {
return releaseYear;
}
@Override
public String getArtworkMrl() {
return artworkMrl;
}
public AArtist getAlbumArtist() {
//TODO
return null;
}
@Override
public int getTracksCount() {
return mTracksCount;
}
public int getDuration() {
return duration;
}
@Override
public AMediaWrapper[] getTracks() {
return getTracks(Medialibrary.SORT_ALBUM, false);
}
@Override
public int getItemType() {
return TYPE_ALBUM;
}
public static Parcelable.Creator<AAlbum> CREATOR
= new Parcelable.Creator<AAlbum>() {
@Override
public AAlbum createFromParcel(Parcel in) {
return ServiceLocator.getAAlbum(in);
}
@Override
public AAlbum[] newArray(int size) {
return new AAlbum[size];
}
};
@Override
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(releaseYear);
parcel.writeString(artworkMrl);
parcel.writeString(albumArtist);
parcel.writeLong(albumArtistId);
parcel.writeInt(mTracksCount);
parcel.writeInt(duration);
}
}
......@@ -7,7 +7,6 @@ import org.videolan.libvlc.util.VLCUtil;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.medialibrary.R;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.media.Album;
import org.videolan.medialibrary.media.MediaLibraryItem;
abstract public class AArtist extends MediaLibraryItem {
......@@ -33,9 +32,9 @@ abstract public class AArtist extends MediaLibraryItem {
}
}
abstract public Album[] getAlbums(int sort, boolean desc);
abstract public Album[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset);
abstract public Album[] searchAlbums(String query, int sort, boolean desc, int nbItems, int offset);
abstract public AAlbum[] getAlbums(int sort, boolean desc);
abstract public AAlbum[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset);
abstract public AAlbum[] searchAlbums(String query, int sort, boolean desc, int nbItems, int offset);
abstract public int searchAlbumsCount(String query);
abstract public AMediaWrapper[] searchTracks(String query, int sort, boolean desc, int nbItems, int offset);
abstract public int searchTracksCount(String query);
......@@ -65,7 +64,7 @@ abstract public class AArtist extends MediaLibraryItem {
this.artworkMrl = artworkMrl;
}
public Album[] getAlbums() {
public AAlbum[] getAlbums() {
return getAlbums(Medialibrary.SORT_DEFAULT, false);
}
......
......@@ -5,7 +5,6 @@ import android.os.Parcelable;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.medialibrary.ServiceLocator;
import org.videolan.medialibrary.media.Album;
import org.videolan.medialibrary.media.MediaLibraryItem;
public abstract class AGenre extends MediaLibraryItem {
......@@ -13,19 +12,19 @@ public abstract class AGenre extends MediaLibraryItem {
public AGenre(long id, String title) { super(id, title); }
public AGenre(Parcel in) { super(in); }
abstract public Album[] getAlbums(int sort, boolean desc);
abstract public Album[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset);
abstract public AAlbum[] getAlbums(int sort, boolean desc);
abstract public AAlbum[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset);
abstract public AArtist[] getArtists(int sort, boolean desc);
abstract public AMediaWrapper[] getTracks(int sort, boolean desc);
abstract public AMediaWrapper[] getPagedTracks(int sort, boolean desc, int nbItems, int offset);
abstract public int getTracksCount();
abstract public int getAlbumsCount();
abstract public Album[] searchAlbums(String query, int sort, boolean desc, int nbItems, int offset);
abstract public AAlbum[] searchAlbums(String query, int sort, boolean desc, int nbItems, int offset);
abstract public int searchAlbumsCount(String query);
abstract public AMediaWrapper[] searchTracks(String query, int sort, boolean desc, int nbItems, int offset);
abstract public int searchTracksCount(String query);
public Album[] getAlbums() {
public AAlbum[] getAlbums() {
return getAlbums(Medialibrary.SORT_DEFAULT, false);
}
public AArtist[] getArtists() {
......
package org.videolan.medialibrary.media;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import org.videolan.libvlc.util.VLCUtil;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.medialibrary.R;
import org.videolan.medialibrary.interfaces.media.AArtist;
import org.videolan.medialibrary.interfaces.media.AAlbum;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
@SuppressWarnings("JniMissingFunction")
public class Album extends MediaLibraryItem {
public class Album extends AAlbum {
public static final String TAG = "VLC/Album";
public static class SpecialRes {
public static String UNKNOWN_ALBUM = Medialibrary.getContext().getString(R.string.unknown_album);
}
private int releaseYear;
private String artworkMrl;
private String albumArtist;
private long albumArtistId;
private int mTracksCount;
private int duration;
public Album(long id, String title, int releaseYear, String artworkMrl, String albumArtist, long albumArtistId, int nbTracks, int duration) {
super(id, title);
this.releaseYear = releaseYear;
this.artworkMrl = artworkMrl != null ? VLCUtil.UriFromMrl(artworkMrl).getPath() : null;
this.albumArtist = albumArtist != null ? albumArtist.trim(): null;
this.albumArtistId = albumArtistId;
this.mTracksCount = nbTracks;
this.duration = duration;
if (TextUtils.isEmpty(title)) mTitle = SpecialRes.UNKNOWN_ALBUM;
if (albumArtistId == 1L) {
this.albumArtist = AArtist.SpecialRes.UNKNOWN_ARTIST;
} else if (albumArtistId == 2L) {
this.albumArtist = AArtist.SpecialRes.VARIOUS_ARTISTS;
}
}
@Override
public long getId() {
return mId;
super(id, title, releaseYear, artworkMrl, albumArtist, albumArtistId, nbTracks, duration);
}
@Override
public String getDescription() {
return albumArtist;
}
public int getReleaseYear() {
return releaseYear;
}
@Override
public String getArtworkMrl() {
return artworkMrl;
}
public AArtist getAlbumArtist() {
//TODO
return null;
}
@Override
public int getTracksCount() {
return mTracksCount;
public Album(Parcel in) {
super(in);
}
public int getRealTracksCount() {
......@@ -74,15 +23,6 @@ public class Album extends MediaLibraryItem {
return ml.isInitiated() ? nativeGetTracksCount(ml, mId) : 0;
}
public int getDuration() {
return duration;
}
@Override
public AMediaWrapper[] getTracks() {
return getTracks(Medialibrary.SORT_ALBUM, false);
}
public AMediaWrapper[] getTracks(int sort, boolean desc) {
Medialibrary ml = Medialibrary.getInstance();
return ml.isInitiated() ? nativeGetTracks(ml, mId, sort, desc) : Medialibrary.EMPTY_COLLECTION;
......@@ -103,48 +43,9 @@ public class Album extends MediaLibraryItem {
return ml.isInitiated() ? nativeGetSearchCount(ml, mId, query) : 0;
}
@Override
public int getItemType() {
return TYPE_ALBUM;
}
private native AMediaWrapper[] nativeGetTracks(Medialibrary ml, long mId, int sort, boolean desc);
private native AMediaWrapper[] nativeGetPagedTracks(Medialibrary ml, long mId, int sort, boolean desc, int nbItems, int offset);
private native AMediaWrapper[] nativeSearch(Medialibrary ml, long mId, String query, int sort, boolean desc, int nbItems, int offset);
private native int nativeGetTracksCount(Medialibrary ml, long id);
private native int nativeGetSearchCount(Medialibrary ml, long mId, String query);
@Override
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(releaseYear);
parcel.writeString(artworkMrl);
parcel.writeString(albumArtist);
parcel.writeLong(albumArtistId);
parcel.writeInt(mTracksCount);
parcel.writeInt(duration);
}
public static Parcelable.Creator<Album> CREATOR
= new Parcelable.Creator<Album>() {
@Override
public Album createFromParcel(Parcel in) {
return new Album(in);
}
@Override
public Album[] newArray(int size) {
return new Album[size];
}
};
private Album(Parcel in) {
super(in);
this.releaseYear = in.readInt();
this.artworkMrl = in.readString();
this.albumArtist = in.readString();
this.albumArtistId = in.readLong();
this.mTracksCount = in.readInt();
this.duration = in.readInt();
}
}
......@@ -3,6 +3,7 @@ package org.videolan.medialibrary.media;
import android.os.Parcel;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.medialibrary.interfaces.media.AAlbum;
import org.videolan.medialibrary.interfaces.media.AArtist;
import org.videolan.medialibrary.interfaces.media.AMediaWrapper;
......@@ -19,20 +20,20 @@ public class Artist extends AArtist {
super(in);
}
public Album[] getAlbums(int sort, boolean desc) {
public AAlbum[] getAlbums(int sort, boolean desc) {
final Medialibrary ml = Medialibrary.getInstance();
return ml.isInitiated() ? nativeGetAlbums(ml, mId, sort, desc) : new Album[0];
return ml.isInitiated() ? nativeGetAlbums(ml, mId, sort, desc) : new AAlbum[0];
}
@NonNull
public Album[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset) {
public AAlbum[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset) {
final Medialibrary ml = Medialibrary.getInstance();
return ml.isInitiated() ? nativeGetPagedAlbums(ml, mId, sort, desc, nbItems, offset) : new Album[0];
return ml.isInitiated() ? nativeGetPagedAlbums(ml, mId, sort, desc, nbItems, offset) : new AAlbum[0];
}
public Album[] searchAlbums(String query, int sort, boolean desc, int nbItems, int offset) {
public AAlbum[] searchAlbums(String query, int sort, boolean desc, int nbItems, int offset) {
final Medialibrary ml = Medialibrary.getInstance();
return ml.isInitiated() ? nativeSearchAlbums(ml, mId, query, sort, desc, nbItems, offset) : new Album[0];
return ml.isInitiated() ? nativeSearchAlbums(ml, mId, query, sort, desc, nbItems, offset) : new AAlbum[0];
}
public int searchAlbumsCount(String query) {
......@@ -71,11 +72,11 @@ public class Artist extends AArtist {
return ml.isInitiated() ? nativeGetTracksCount(ml, mId) : 0;
}
private native Album[] nativeGetAlbums(Medialibrary ml, long mId, int sort, boolean desc);
private native AAlbum[] nativeGetAlbums(Medialibrary ml, long mId, int sort, boolean desc);
private native AMediaWrapper[] nativeGetMedia(Medialibrary ml, long mId, int sort, boolean desc);
private native Album[] nativeGetPagedAlbums(Medialibrary ml, long mId, int sort, boolean desc, int nbItems, int offset);
private native AAlbum[] nativeGetPagedAlbums(Medialibrary ml, long mId, int sort, boolean desc, int nbItems, int offset);
private native AMediaWrapper[] nativeGetPagedMedia(Medialibrary ml, long mId, int sort, boolean desc, int nbItems, int offset);
private native Album[] nativeSearchAlbums(Medialibrary ml, long mId, String query, int sort, boolean desc, int nbItems, int offset);