mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Refactor Song model to Media model
This commit is contained in:
parent
4713ff3c90
commit
c3c214a6e2
1 changed files with 202 additions and 135 deletions
|
|
@ -6,17 +6,15 @@ import android.os.Parcelable;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import com.cappielloantonio.play.subsonic.models.PodcastEpisode;
|
||||
|
||||
public class Media implements Parcelable {
|
||||
private static final String TAG = "Media";
|
||||
|
||||
public static String MEDIA_TYPE_MUSIC = "music";
|
||||
public static String MEDIA_TYPE_PODCAST = "podcast";
|
||||
public static String MEDIA_TYPE_AUDIOBOOK = "audiobook";
|
||||
public static String MEDIA_TYPE_VIDEO = "video";
|
||||
public static final String MEDIA_TYPE_MUSIC = "music";
|
||||
public static final String MEDIA_TYPE_PODCAST = "podcast";
|
||||
public static final String MEDIA_TYPE_AUDIOBOOK = "audiobook";
|
||||
public static final String MEDIA_TYPE_VIDEO = "video";
|
||||
|
||||
public static final String RECENTLY_PLAYED = "RECENTLY_PLAYED";
|
||||
public static final String MOST_PLAYED = "MOST_PLAYED";
|
||||
|
|
@ -31,17 +29,20 @@ public class Media implements Parcelable {
|
|||
|
||||
private String id;
|
||||
private String title;
|
||||
private int trackNumber;
|
||||
private int discNumber;
|
||||
private int year;
|
||||
private long duration;
|
||||
private String channelId;
|
||||
private String streamId;
|
||||
private String albumId;
|
||||
private String albumName;
|
||||
private String artistId;
|
||||
private String artistName;
|
||||
private String primary;
|
||||
private String blurHash;
|
||||
private boolean favorite;
|
||||
private String coverArtId;
|
||||
private int trackNumber;
|
||||
private int discNumber;
|
||||
private int year;
|
||||
private long duration;
|
||||
private String description;
|
||||
private String status;
|
||||
private boolean starred;
|
||||
private String path;
|
||||
private long size;
|
||||
private String container;
|
||||
|
|
@ -51,16 +52,7 @@ public class Media implements Parcelable {
|
|||
private int playCount;
|
||||
private long lastPlay;
|
||||
private int rating;
|
||||
|
||||
private String streamId;
|
||||
private String channelId;
|
||||
private String description;
|
||||
private String status;
|
||||
private Date publishDate;
|
||||
|
||||
public Media() {
|
||||
this.id = UUID.randomUUID().toString();
|
||||
}
|
||||
private long publishDate;
|
||||
|
||||
public Media(Child child) {
|
||||
this.id = child.getId();
|
||||
|
|
@ -73,8 +65,8 @@ public class Media implements Parcelable {
|
|||
this.albumName = child.getAlbum();
|
||||
this.artistId = child.getArtistId();
|
||||
this.artistName = child.getArtist();
|
||||
this.primary = child.getCoverArtId();
|
||||
this.favorite = child.getStarred() != null;
|
||||
this.coverArtId = child.getCoverArtId();
|
||||
this.starred = child.getStarred() != null;
|
||||
this.path = child.getPath();
|
||||
this.size = child.getSize();
|
||||
this.container = child.getContentType();
|
||||
|
|
@ -83,17 +75,40 @@ public class Media implements Parcelable {
|
|||
this.playCount = 0;
|
||||
this.lastPlay = 0;
|
||||
this.rating = child.getUserRating() != null ? child.getUserRating() : 0;
|
||||
this.type = child.getType();
|
||||
}
|
||||
|
||||
public Media(PodcastEpisode podcastEpisode) {
|
||||
this.id = podcastEpisode.getId();
|
||||
this.title = podcastEpisode.getTitle();
|
||||
this.albumName = podcastEpisode.getAlbum();
|
||||
this.artistName = podcastEpisode.getArtist();
|
||||
this.trackNumber = podcastEpisode.getTrack() != null ? podcastEpisode.getTrack() : 0;
|
||||
this.year = podcastEpisode.getYear();
|
||||
this.coverArtId = podcastEpisode.getCoverArtId();
|
||||
this.duration = podcastEpisode.getDuration();
|
||||
this.starred = podcastEpisode.getStarred() != null;
|
||||
this.streamId = podcastEpisode.getStreamId();
|
||||
this.channelId = podcastEpisode.getChannelId();
|
||||
this.description = podcastEpisode.getDescription();
|
||||
this.status = podcastEpisode.getStatus();
|
||||
this.publishDate = podcastEpisode.getPublishDate().getTime();
|
||||
this.type = podcastEpisode.getType();
|
||||
}
|
||||
|
||||
public Media(Queue queue) {
|
||||
this.id = queue.getSongID();
|
||||
this.id = queue.getId();
|
||||
this.title = queue.getTitle();
|
||||
this.albumId = queue.getAlbumId();
|
||||
this.albumName = queue.getAlbumName();
|
||||
this.artistId = queue.getArtistId();
|
||||
this.artistName = queue.getArtistName();
|
||||
this.primary = queue.getPrimary();
|
||||
this.coverArtId = queue.getCoverArtId();
|
||||
this.duration = queue.getDuration();
|
||||
this.streamId = queue.getStreamId();
|
||||
this.channelId = queue.getChannelId();
|
||||
this.publishDate = queue.getPublishingDate();
|
||||
this.type = queue.getType();
|
||||
}
|
||||
|
||||
public Media(Download download) {
|
||||
|
|
@ -104,7 +119,7 @@ public class Media implements Parcelable {
|
|||
this.artistId = download.getArtistId();
|
||||
this.artistName = download.getArtistName();
|
||||
this.trackNumber = download.getTrackNumber();
|
||||
this.primary = download.getPrimary();
|
||||
this.coverArtId = download.getPrimary();
|
||||
this.duration = download.getDuration();
|
||||
}
|
||||
|
||||
|
|
@ -112,162 +127,194 @@ public class Media implements Parcelable {
|
|||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public int getTrackNumber() {
|
||||
return trackNumber;
|
||||
}
|
||||
|
||||
public int getDiscNumber() {
|
||||
return discNumber;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public String getAlbumId() {
|
||||
return albumId;
|
||||
}
|
||||
|
||||
public String getAlbumName() {
|
||||
return albumName;
|
||||
}
|
||||
|
||||
public String getArtistId() {
|
||||
return artistId;
|
||||
}
|
||||
|
||||
public String getArtistName() {
|
||||
return artistName;
|
||||
}
|
||||
|
||||
public String getPrimary() {
|
||||
return primary;
|
||||
}
|
||||
|
||||
public String getBlurHash() {
|
||||
return blurHash;
|
||||
}
|
||||
|
||||
public boolean isFavorite() {
|
||||
return favorite;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
public int getBitRate() {
|
||||
return bitRate;
|
||||
}
|
||||
|
||||
public long getAdded() {
|
||||
return added;
|
||||
}
|
||||
|
||||
public int getPlayCount() {
|
||||
return playCount;
|
||||
}
|
||||
|
||||
public long getLastPlay() {
|
||||
return lastPlay;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setTrackNumber(int trackNumber) {
|
||||
this.trackNumber = trackNumber;
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
}
|
||||
|
||||
public void setDiscNumber(int discNumber) {
|
||||
this.discNumber = discNumber;
|
||||
public void setChannelId(String channelId) {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public void setYear(int year) {
|
||||
this.year = year;
|
||||
public String getStreamId() {
|
||||
return streamId;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
public void setStreamId(String streamId) {
|
||||
this.streamId = streamId;
|
||||
}
|
||||
|
||||
public String getAlbumId() {
|
||||
return albumId;
|
||||
}
|
||||
|
||||
public void setAlbumId(String albumId) {
|
||||
this.albumId = albumId;
|
||||
}
|
||||
|
||||
public String getAlbumName() {
|
||||
return albumName;
|
||||
}
|
||||
|
||||
public void setAlbumName(String albumName) {
|
||||
this.albumName = albumName;
|
||||
}
|
||||
|
||||
public String getArtistId() {
|
||||
return artistId;
|
||||
}
|
||||
|
||||
public void setArtistId(String artistId) {
|
||||
this.artistId = artistId;
|
||||
}
|
||||
|
||||
public String getArtistName() {
|
||||
return artistName;
|
||||
}
|
||||
|
||||
public void setArtistName(String artistName) {
|
||||
this.artistName = artistName;
|
||||
}
|
||||
|
||||
public void setPrimary(String primary) {
|
||||
this.primary = primary;
|
||||
public String getCoverArtId() {
|
||||
return coverArtId;
|
||||
}
|
||||
|
||||
public void setBlurHash(String blurHash) {
|
||||
this.blurHash = blurHash;
|
||||
public void setCoverArtId(String coverArtId) {
|
||||
this.coverArtId = coverArtId;
|
||||
}
|
||||
|
||||
public void setFavorite(boolean favorite) {
|
||||
this.favorite = favorite;
|
||||
public int getTrackNumber() {
|
||||
return trackNumber;
|
||||
}
|
||||
|
||||
public void setTrackNumber(int trackNumber) {
|
||||
this.trackNumber = trackNumber;
|
||||
}
|
||||
|
||||
public int getDiscNumber() {
|
||||
return discNumber;
|
||||
}
|
||||
|
||||
public void setDiscNumber(int discNumber) {
|
||||
this.discNumber = discNumber;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(int year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public boolean isStarred() {
|
||||
return starred;
|
||||
}
|
||||
|
||||
public void setStarred(boolean starred) {
|
||||
this.starred = starred;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
public void setContainer(String container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public int getBitRate() {
|
||||
return bitRate;
|
||||
}
|
||||
|
||||
public void setBitRate(int bitRate) {
|
||||
this.bitRate = bitRate;
|
||||
}
|
||||
|
||||
public long getAdded() {
|
||||
return added;
|
||||
}
|
||||
|
||||
public void setAdded(long added) {
|
||||
this.added = added;
|
||||
}
|
||||
|
||||
public void setLastPlay(long lastPlay) {
|
||||
this.lastPlay = lastPlay;
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getPlayCount() {
|
||||
return playCount;
|
||||
}
|
||||
|
||||
public void setPlayCount(int playCount) {
|
||||
this.playCount = playCount;
|
||||
}
|
||||
|
||||
public long getLastPlay() {
|
||||
return lastPlay;
|
||||
}
|
||||
|
||||
public void setLastPlay(long lastPlay) {
|
||||
this.lastPlay = lastPlay;
|
||||
}
|
||||
|
||||
public int getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
|
@ -276,6 +323,14 @@ public class Media implements Parcelable {
|
|||
this.rating = rating;
|
||||
}
|
||||
|
||||
public long getPublishDate() {
|
||||
return publishDate;
|
||||
}
|
||||
|
||||
public void setPublishDate(long publishDate) {
|
||||
this.publishDate = publishDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
|
@ -305,47 +360,59 @@ public class Media implements Parcelable {
|
|||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(this.id);
|
||||
dest.writeString(this.title);
|
||||
dest.writeInt(this.trackNumber);
|
||||
dest.writeInt(this.discNumber);
|
||||
dest.writeInt(this.year);
|
||||
dest.writeLong(this.duration);
|
||||
dest.writeString(this.channelId);
|
||||
dest.writeString(this.streamId);
|
||||
dest.writeString(this.albumId);
|
||||
dest.writeString(this.albumName);
|
||||
dest.writeString(this.artistId);
|
||||
dest.writeString(this.artistName);
|
||||
dest.writeString(this.primary);
|
||||
dest.writeString(Boolean.toString(favorite));
|
||||
dest.writeString(this.blurHash);
|
||||
dest.writeString(this.coverArtId);
|
||||
dest.writeInt(this.trackNumber);
|
||||
dest.writeInt(this.discNumber);
|
||||
dest.writeInt(this.year);
|
||||
dest.writeLong(this.duration);
|
||||
dest.writeString(this.description);
|
||||
dest.writeString(this.status);
|
||||
dest.writeString(Boolean.toString(starred));
|
||||
dest.writeString(this.path);
|
||||
dest.writeLong(this.size);
|
||||
dest.writeString(this.container);
|
||||
dest.writeInt(this.bitRate);
|
||||
dest.writeLong(this.added);
|
||||
dest.writeString(this.type);
|
||||
dest.writeInt(this.playCount);
|
||||
dest.writeLong(this.lastPlay);
|
||||
dest.writeInt(this.rating);
|
||||
dest.writeLong(this.publishDate);
|
||||
}
|
||||
|
||||
protected Media(Parcel in) {
|
||||
this.id = in.readString();
|
||||
this.title = in.readString();
|
||||
this.trackNumber = in.readInt();
|
||||
this.discNumber = in.readInt();
|
||||
this.year = in.readInt();
|
||||
this.duration = in.readLong();
|
||||
this.channelId = in.readString();
|
||||
this.streamId = in.readString();
|
||||
this.albumId = in.readString();
|
||||
this.albumName = in.readString();
|
||||
this.artistId = in.readString();
|
||||
this.artistName = in.readString();
|
||||
this.primary = in.readString();
|
||||
this.favorite = Boolean.parseBoolean(in.readString());
|
||||
this.blurHash = in.readString();
|
||||
this.coverArtId = in.readString();
|
||||
this.trackNumber = in.readInt();
|
||||
this.discNumber = in.readInt();
|
||||
this.year = in.readInt();
|
||||
this.duration = in.readLong();
|
||||
this.description = in.readString();
|
||||
this.status = in.readString();
|
||||
this.starred = Boolean.parseBoolean(in.readString());
|
||||
this.path = in.readString();
|
||||
this.size = in.readLong();
|
||||
this.container = in.readString();
|
||||
this.bitRate = in.readInt();
|
||||
this.added = in.readLong();
|
||||
this.type = in.readString();
|
||||
this.playCount = in.readInt();
|
||||
this.lastPlay = in.readLong();
|
||||
this.rating = in.readInt();
|
||||
this.publishDate = in.readLong();
|
||||
}
|
||||
|
||||
public static final Creator<Media> CREATOR = new Creator<Media>() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue