mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-01 15:03:37 +00:00
Added discover/recentryAddedAlbum/recentlyPlayedAlbum/mostPlayedAlbum data retrieval
This commit is contained in:
@@ -10,6 +10,8 @@ import androidx.room.Entity;
|
||||
import androidx.room.Ignore;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumID3;
|
||||
|
||||
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
||||
import org.jellyfin.apiclient.model.entities.ImageType;
|
||||
|
||||
@@ -21,19 +23,6 @@ import java.util.UUID;
|
||||
public class Album implements Parcelable {
|
||||
private static final String TAG = "Album";
|
||||
|
||||
@Ignore
|
||||
public List<Song> songs;
|
||||
|
||||
/*
|
||||
* TODO: Da capire chi tra albumArtist e artistItems sono i compositori e suonatori dell'album, oppure le comparse
|
||||
* In teoria AlbumArtist sono i creatori, mentre ArtistItems le comparse
|
||||
*/
|
||||
@Ignore
|
||||
public List<Artist> albumArtists;
|
||||
|
||||
@Ignore
|
||||
public List<Artist> artistItems;
|
||||
|
||||
@NonNull
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = "id")
|
||||
@@ -68,37 +57,14 @@ public class Album implements Parcelable {
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public Album(BaseItemDto itemDto) {
|
||||
this.id = itemDto.getId();
|
||||
this.title = itemDto.getName();
|
||||
this.year = itemDto.getProductionYear() != null ? itemDto.getProductionYear() : 0;
|
||||
|
||||
albumArtists = new ArrayList<>();
|
||||
artistItems = new ArrayList<>();
|
||||
|
||||
if (itemDto.getAlbumArtists().size() != 0) {
|
||||
this.artistId = itemDto.getAlbumArtists().get(0).getId();
|
||||
this.artistName = itemDto.getAlbumArtists().get(0).getName();
|
||||
|
||||
itemDto.getAlbumArtists().forEach(artist -> {
|
||||
albumArtists.add(new Artist(artist.getId(), artist.getName()));
|
||||
});
|
||||
}
|
||||
else if (itemDto.getArtistItems().size() != 0) {
|
||||
this.artistId = itemDto.getArtistItems().get(0).getId();
|
||||
this.artistName = itemDto.getArtistItems().get(0).getName();
|
||||
|
||||
itemDto.getArtistItems().forEach(artist -> {
|
||||
artistItems.add(new Artist(artist.getId(), artist.getName()));
|
||||
});
|
||||
}
|
||||
|
||||
this.primary = itemDto.getImageTags().containsKey(ImageType.Primary) ? id : null;
|
||||
if (itemDto.getImageBlurHashes() != null && itemDto.getImageBlurHashes().get(ImageType.Primary) != null) {
|
||||
this.blurHash = (String) itemDto.getImageBlurHashes().get(ImageType.Primary).values().toArray()[0];
|
||||
}
|
||||
|
||||
this.songs = new ArrayList<>();
|
||||
public Album(AlbumID3 albumID3) {
|
||||
this.id = albumID3.getId();
|
||||
this.title = albumID3.getName();
|
||||
this.year = albumID3.getYear();
|
||||
this.artistId = albumID3.getArtistId();
|
||||
this.artistName = albumID3.getArtist();
|
||||
this.primary = albumID3.getCoverArtId();
|
||||
this.blurHash = blurHash;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -195,8 +161,6 @@ public class Album implements Parcelable {
|
||||
}
|
||||
|
||||
protected Album(Parcel in) {
|
||||
this.songs = new ArrayList<>();
|
||||
|
||||
this.id = in.readString();
|
||||
this.title = in.readString();
|
||||
this.year = in.readInt();
|
||||
|
||||
@@ -93,6 +93,9 @@ public class Song implements Parcelable {
|
||||
@ColumnInfo(name = "primary")
|
||||
private String primary;
|
||||
|
||||
@ColumnInfo(name = "blurHash")
|
||||
private String blurHash;
|
||||
|
||||
@ColumnInfo(name = "favorite")
|
||||
private boolean favorite;
|
||||
|
||||
@@ -120,7 +123,7 @@ public class Song implements Parcelable {
|
||||
@ColumnInfo(name = "offline")
|
||||
private boolean offline;
|
||||
|
||||
public Song(@NonNull String id, String title, int trackNumber, int discNumber, int year, long duration, String albumId, String albumName, String artistId, String artistName, String primary, boolean favorite, String path, long size, String container, int bitRate, long added, int playCount, long lastPlay, boolean offline) {
|
||||
public Song(@NonNull String id, String title, int trackNumber, int discNumber, int year, long duration, String albumId, String albumName, String artistId, String artistName, String primary, String blurHash, boolean favorite, String path, long size, String container, int bitRate, long added, int playCount, long lastPlay, boolean offline) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.trackNumber = trackNumber;
|
||||
@@ -132,6 +135,7 @@ public class Song implements Parcelable {
|
||||
this.artistId = artistId;
|
||||
this.artistName = artistName;
|
||||
this.primary = primary;
|
||||
this.blurHash = blurHash;
|
||||
this.favorite = favorite;
|
||||
this.path = path;
|
||||
this.size = size;
|
||||
@@ -154,7 +158,7 @@ public class Song implements Parcelable {
|
||||
this.title = child.getTitle();
|
||||
this.trackNumber = child.getTrack();
|
||||
this.discNumber = child.getDiscNumber();
|
||||
this.year = child.getYear();
|
||||
this.year = child.getYear() != null ? child.getYear() : 0;
|
||||
this.duration = child.getDuration();
|
||||
this.albumId = child.getAlbumId();
|
||||
this.albumName = child.getAlbum();
|
||||
@@ -217,6 +221,10 @@ public class Song implements Parcelable {
|
||||
return primary;
|
||||
}
|
||||
|
||||
public String getBlurHash() {
|
||||
return blurHash;
|
||||
}
|
||||
|
||||
public boolean isFavorite() {
|
||||
return favorite;
|
||||
}
|
||||
@@ -297,6 +305,10 @@ public class Song implements Parcelable {
|
||||
this.primary = primary;
|
||||
}
|
||||
|
||||
public void setBlurHash(String blurHash) {
|
||||
this.blurHash = blurHash;
|
||||
}
|
||||
|
||||
public void setFavorite(boolean favorite) {
|
||||
this.favorite = favorite;
|
||||
}
|
||||
@@ -390,6 +402,7 @@ public class Song implements Parcelable {
|
||||
dest.writeString(this.artistName);
|
||||
dest.writeString(this.primary);
|
||||
dest.writeString(Boolean.toString(favorite));
|
||||
dest.writeString(this.blurHash);
|
||||
dest.writeString(this.path);
|
||||
dest.writeLong(this.size);
|
||||
dest.writeString(this.container);
|
||||
@@ -414,6 +427,7 @@ public class Song implements Parcelable {
|
||||
this.artistName = in.readString();
|
||||
this.primary = in.readString();
|
||||
this.favorite = Boolean.parseBoolean(in.readString());
|
||||
this.blurHash = in.readString();
|
||||
this.path = in.readString();
|
||||
this.size = in.readLong();
|
||||
this.container = in.readString();
|
||||
|
||||
Reference in New Issue
Block a user