mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Refactor Song to Media
This commit is contained in:
parent
62f2723014
commit
d1d341ff9b
43 changed files with 242 additions and 274 deletions
|
|
@ -21,7 +21,7 @@ import com.cappielloantonio.play.R;
|
|||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
|
|
@ -130,7 +130,7 @@ public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder
|
|||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
if (media.size() > 0) {
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, context, (ArrayList<Song>) media, 0);
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, context, (ArrayList<Media>) media, 0);
|
||||
mainActivity.setBottomSheetInPeek(true);
|
||||
} else {
|
||||
Toast.makeText(context, context.getString(R.string.artist_error_retrieving_radio), Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ import com.cappielloantonio.play.App;
|
|||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
|
|
@ -36,7 +35,7 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
|
|||
private final MainActivity activity;
|
||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||
|
||||
private List<Song> songs;
|
||||
private List<Media> songs;
|
||||
|
||||
public DiscoverSongAdapter(MainActivity activity, Context context) {
|
||||
this.activity = activity;
|
||||
|
|
@ -54,7 +53,7 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Song song = songs.get(position);
|
||||
Media song = songs.get(position);
|
||||
|
||||
holder.textTitle.setText(MusicUtil.getReadableString(song.getTitle()));
|
||||
holder.textAlbum.setText(MusicUtil.getReadableString(song.getAlbumName()));
|
||||
|
|
@ -76,7 +75,7 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
|
|||
return songs.size();
|
||||
}
|
||||
|
||||
public void setItems(List<Song> songs) {
|
||||
public void setItems(List<Media> songs) {
|
||||
this.songs = songs;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
|
@ -114,7 +113,7 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
|
|||
|
||||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, context, (List<Song>) media,false);
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, context, (List<Media>) media,false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.ui.fragment.PlayerBottomSheetFragment;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
|
|
@ -30,7 +29,7 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
|||
private final Context context;
|
||||
|
||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||
private List<Song> songs;
|
||||
private List<Media> songs;
|
||||
|
||||
public PlayerSongQueueAdapter(Context context) {
|
||||
this.context = context;
|
||||
|
|
@ -47,7 +46,7 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Song song = songs.get(position);
|
||||
Media song = songs.get(position);
|
||||
|
||||
holder.songTitle.setText(MusicUtil.getReadableString(song.getTitle()));
|
||||
holder.songSubtitle.setText(context.getString(R.string.song_subtitle_formatter, MusicUtil.getReadableString(song.getArtistName()), MusicUtil.getReadableDurationString(song.getDuration(), false)));
|
||||
|
|
@ -71,11 +70,11 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
|||
return songs.size();
|
||||
}
|
||||
|
||||
public List<Song> getItems() {
|
||||
public List<Media> getItems() {
|
||||
return this.songs;
|
||||
}
|
||||
|
||||
public void setItems(List<Song> songs) {
|
||||
public void setItems(List<Media> songs) {
|
||||
this.songs = songs;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
|
@ -84,7 +83,7 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
|||
this.mediaBrowserListenableFuture = mediaBrowserListenableFuture;
|
||||
}
|
||||
|
||||
public Song getItem(int id) {
|
||||
public Media getItem(int id) {
|
||||
return songs.get(id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||
public class PlaylistDialogSongHorizontalAdapter extends RecyclerView.Adapter<PlaylistDialogSongHorizontalAdapter.ViewHolder> {
|
||||
private static final String TAG = "PlaylistDialogSongHorizontalAdapter";
|
||||
|
||||
private List<Song> songs;
|
||||
private List<Media> songs;
|
||||
private final LayoutInflater mInflater;
|
||||
private final Context context;
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ public class PlaylistDialogSongHorizontalAdapter extends RecyclerView.Adapter<Pl
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Song song = songs.get(position);
|
||||
Media song = songs.get(position);
|
||||
|
||||
holder.songTitle.setText(MusicUtil.getReadableString(song.getTitle()));
|
||||
holder.songArtist.setText(MusicUtil.getReadableString(song.getArtistName()));
|
||||
|
|
@ -59,16 +59,16 @@ public class PlaylistDialogSongHorizontalAdapter extends RecyclerView.Adapter<Pl
|
|||
return songs.size();
|
||||
}
|
||||
|
||||
public List<Song> getItems() {
|
||||
public List<Media> getItems() {
|
||||
return this.songs;
|
||||
}
|
||||
|
||||
public void setItems(List<Song> songs) {
|
||||
public void setItems(List<Media> songs) {
|
||||
this.songs = songs;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public Song getItem(int id) {
|
||||
public Media getItem(int id) {
|
||||
return songs.get(id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import com.cappielloantonio.play.App;
|
|||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
|
|
@ -37,7 +37,7 @@ public class SimilarTrackAdapter extends RecyclerView.Adapter<SimilarTrackAdapte
|
|||
private final LayoutInflater mInflater;
|
||||
|
||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||
private List<Song> songs;
|
||||
private List<Media> songs;
|
||||
|
||||
public SimilarTrackAdapter(MainActivity activity, Context context) {
|
||||
this.activity = activity;
|
||||
|
|
@ -55,7 +55,7 @@ public class SimilarTrackAdapter extends RecyclerView.Adapter<SimilarTrackAdapte
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Song song = songs.get(position);
|
||||
Media song = songs.get(position);
|
||||
|
||||
holder.textTitle.setText(MusicUtil.getReadableString(song.getTitle()));
|
||||
|
||||
|
|
@ -71,11 +71,11 @@ public class SimilarTrackAdapter extends RecyclerView.Adapter<SimilarTrackAdapte
|
|||
return songs.size();
|
||||
}
|
||||
|
||||
public Song getItem(int position) {
|
||||
public Media getItem(int position) {
|
||||
return songs.get(position);
|
||||
}
|
||||
|
||||
public void setItems(List<Song> songs) {
|
||||
public void setItems(List<Media> songs) {
|
||||
this.songs = songs;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ public class SimilarTrackAdapter extends RecyclerView.Adapter<SimilarTrackAdapte
|
|||
|
||||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, context, (List<Song>) media, false);
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, context, (List<Media>) media, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
|
|
@ -36,7 +36,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
private final boolean isCoverVisible;
|
||||
|
||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||
private List<Song> songs;
|
||||
private List<Media> songs;
|
||||
|
||||
public SongHorizontalAdapter(MainActivity mainActivity, Context context, boolean isCoverVisible) {
|
||||
this.mainActivity = mainActivity;
|
||||
|
|
@ -55,7 +55,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Song song = songs.get(position);
|
||||
Media song = songs.get(position);
|
||||
|
||||
holder.songTitle.setText(MusicUtil.getReadableString(song.getTitle()));
|
||||
holder.songSubtitle.setText(context.getString(R.string.song_subtitle_formatter, MusicUtil.getReadableString(song.getArtistName()), MusicUtil.getReadableDurationString(song.getDuration(), false)));
|
||||
|
|
@ -83,7 +83,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
return songs.size();
|
||||
}
|
||||
|
||||
public void setItems(List<Song> songs) {
|
||||
public void setItems(List<Media> songs) {
|
||||
this.songs = songs;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
this.mediaBrowserListenableFuture = mediaBrowserListenableFuture;
|
||||
}
|
||||
|
||||
public Song getItem(int id) {
|
||||
public Media getItem(int id) {
|
||||
return songs.get(id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class Album implements Parcelable {
|
|||
private String primary;
|
||||
private String blurHash;
|
||||
private boolean favorite;
|
||||
private List<Song> songs;
|
||||
private List<Media> songs;
|
||||
private String notes;
|
||||
private Date created;
|
||||
|
||||
|
|
@ -135,11 +135,11 @@ public class Album implements Parcelable {
|
|||
this.favorite = favorite;
|
||||
}
|
||||
|
||||
public List<Song> getSongs() {
|
||||
public List<Media> getSongs() {
|
||||
return songs;
|
||||
}
|
||||
|
||||
public void setSongs(List<Song> songs) {
|
||||
public void setSongs(List<Media> songs) {
|
||||
this.songs = songs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class Download {
|
|||
this.playlistName = playlistName;
|
||||
}
|
||||
|
||||
public Download(Song song, String playlistId, String playlistName) {
|
||||
public Download(Media song, String playlistId, String playlistName) {
|
||||
this.id = UUID.randomUUID().toString();
|
||||
this.songID = song.getId();
|
||||
this.title = song.getTitle();
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Song implements Parcelable {
|
||||
private static final String TAG = "SongClass";
|
||||
public class Media implements Parcelable {
|
||||
private static final String TAG = "Media";
|
||||
|
||||
public static final String RECENTLY_PLAYED = "RECENTLY_PLAYED";
|
||||
public static final String MOST_PLAYED = "MOST_PLAYED";
|
||||
|
|
@ -42,15 +42,16 @@ public class Song implements Parcelable {
|
|||
private String container;
|
||||
private int bitRate;
|
||||
private long added;
|
||||
private String type;
|
||||
private int playCount;
|
||||
private long lastPlay;
|
||||
private int rating;
|
||||
|
||||
public Song() {
|
||||
public Media() {
|
||||
this.id = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public Song(Child child) {
|
||||
public Media(Child child) {
|
||||
this.id = child.getId();
|
||||
this.title = child.getTitle();
|
||||
this.trackNumber = child.getTrack() != null ? child.getTrack() : 0;
|
||||
|
|
@ -73,7 +74,7 @@ public class Song implements Parcelable {
|
|||
this.rating = child.getUserRating() != null ? child.getUserRating() : 0;
|
||||
}
|
||||
|
||||
public Song(Queue queue) {
|
||||
public Media(Queue queue) {
|
||||
this.id = queue.getSongID();
|
||||
this.title = queue.getTitle();
|
||||
this.albumId = queue.getAlbumId();
|
||||
|
|
@ -84,7 +85,7 @@ public class Song implements Parcelable {
|
|||
this.duration = queue.getDuration();
|
||||
}
|
||||
|
||||
public Song(Download download) {
|
||||
public Media(Download download) {
|
||||
this.id = download.getSongID();
|
||||
this.title = download.getTitle();
|
||||
this.albumId = download.getAlbumId();
|
||||
|
|
@ -269,7 +270,7 @@ public class Song implements Parcelable {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Song song = (Song) o;
|
||||
Media song = (Media) o;
|
||||
return id.equals(song.id);
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +314,7 @@ public class Song implements Parcelable {
|
|||
dest.writeLong(this.lastPlay);
|
||||
}
|
||||
|
||||
protected Song(Parcel in) {
|
||||
protected Media(Parcel in) {
|
||||
this.id = in.readString();
|
||||
this.title = in.readString();
|
||||
this.trackNumber = in.readInt();
|
||||
|
|
@ -336,13 +337,13 @@ public class Song implements Parcelable {
|
|||
this.lastPlay = in.readLong();
|
||||
}
|
||||
|
||||
public static final Creator<Song> CREATOR = new Creator<Song>() {
|
||||
public Song createFromParcel(Parcel source) {
|
||||
return new Song(source);
|
||||
public static final Creator<Media> CREATOR = new Creator<Media>() {
|
||||
public Media createFromParcel(Parcel source) {
|
||||
return new Media(source);
|
||||
}
|
||||
|
||||
public Song[] newArray(int size) {
|
||||
return new Song[size];
|
||||
public Media[] newArray(int size) {
|
||||
return new Media[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ import com.cappielloantonio.play.App;
|
|||
import com.cappielloantonio.play.interfaces.DecadesCallback;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
||||
|
|
@ -140,8 +140,8 @@ public class AlbumRepository {
|
|||
});
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getAlbumTracks(String id) {
|
||||
MutableLiveData<List<Song>> albumTracks = new MutableLiveData<>();
|
||||
public MutableLiveData<List<Media>> getAlbumTracks(String id) {
|
||||
MutableLiveData<List<Media>> albumTracks = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
|
|
@ -149,7 +149,7 @@ public class AlbumRepository {
|
|||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
List<Song> tracks = new ArrayList<>();
|
||||
List<Media> tracks = new ArrayList<>();
|
||||
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getAlbum() != null) {
|
||||
tracks.addAll(MappingUtil.mapSong(response.body().getAlbum().getSongs()));
|
||||
|
|
@ -248,7 +248,7 @@ public class AlbumRepository {
|
|||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
List<Media> songs = new ArrayList<>();
|
||||
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getSimilarSongs2() != null) {
|
||||
songs.addAll(MappingUtil.mapSong(response.body().getSimilarSongs2().getSongs()));
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import com.cappielloantonio.play.App;
|
|||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.subsonic.models.IndexID3;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
|
@ -251,7 +251,7 @@ public class ArtistRepository {
|
|||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
List<Media> songs = new ArrayList<>();
|
||||
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getSimilarSongs2() != null) {
|
||||
songs.addAll(MappingUtil.mapSong(response.body().getSimilarSongs2().getSongs()));
|
||||
|
|
@ -267,8 +267,8 @@ public class ArtistRepository {
|
|||
});
|
||||
}
|
||||
|
||||
public MutableLiveData<ArrayList<Song>> getArtistRandomSong(FragmentActivity fragmentActivity, Artist artist, int count) {
|
||||
MutableLiveData<ArrayList<Song>> randomSongs = new MutableLiveData<>();
|
||||
public MutableLiveData<ArrayList<Media>> getArtistRandomSong(FragmentActivity fragmentActivity, Artist artist, int count) {
|
||||
MutableLiveData<ArrayList<Media>> randomSongs = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
|
|
@ -284,7 +284,7 @@ public class ArtistRepository {
|
|||
|
||||
for (int index = 0; index < albums.size(); index++) {
|
||||
albumRepository.getAlbumTracks(albums.get(index).getId()).observe(fragmentActivity, songs -> {
|
||||
ArrayList<Song> liveSongs = randomSongs.getValue();
|
||||
ArrayList<Media> liveSongs = randomSongs.getValue();
|
||||
if (liveSongs == null) liveSongs = new ArrayList<>();
|
||||
Collections.shuffle(liveSongs);
|
||||
liveSongs.addAll(songs);
|
||||
|
|
@ -304,8 +304,8 @@ public class ArtistRepository {
|
|||
return randomSongs;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getTopSongs(String artistName, int count) {
|
||||
MutableLiveData<List<Song>> topSongs = new MutableLiveData<>();
|
||||
public MutableLiveData<List<Media>> getTopSongs(String artistName, int count) {
|
||||
MutableLiveData<List<Media>> topSongs = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
|
|
|
|||
|
|
@ -9,10 +9,8 @@ import androidx.lifecycle.MutableLiveData;
|
|||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
import com.cappielloantonio.play.database.dao.PlaylistDao;
|
||||
import com.cappielloantonio.play.database.dao.ServerDao;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Server;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
||||
|
|
@ -63,8 +61,8 @@ public class PlaylistRepository {
|
|||
return listLivePlaylists;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getPlaylistSongs(String id) {
|
||||
MutableLiveData<List<Song>> listLivePlaylistSongs = new MutableLiveData<>();
|
||||
public MutableLiveData<List<Media>> getPlaylistSongs(String id) {
|
||||
MutableLiveData<List<Media>> listLivePlaylistSongs = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getPlaylistClient()
|
||||
|
|
@ -73,7 +71,7 @@ public class PlaylistRepository {
|
|||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getPlaylist() != null) {
|
||||
List<Song> songs = new ArrayList<>(MappingUtil.mapSong(response.body().getPlaylist().getEntries()));
|
||||
List<Media> songs = new ArrayList<>(MappingUtil.mapSong(response.body().getPlaylist().getEntries()));
|
||||
listLivePlaylistSongs.setValue(songs);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import androidx.lifecycle.LiveData;
|
|||
import com.cappielloantonio.play.database.AppDatabase;
|
||||
import com.cappielloantonio.play.database.dao.QueueDao;
|
||||
import com.cappielloantonio.play.model.Queue;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
||||
import java.time.Instant;
|
||||
|
|
@ -28,8 +28,8 @@ public class QueueRepository {
|
|||
return queueDao.getAll();
|
||||
}
|
||||
|
||||
public List<Song> getSongs() {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
public List<Media> getSongs() {
|
||||
List<Media> songs = new ArrayList<>();
|
||||
|
||||
GetSongsThreadSafe getSongs = new GetSongsThreadSafe(queueDao);
|
||||
Thread thread = new Thread(getSongs);
|
||||
|
|
@ -45,9 +45,9 @@ public class QueueRepository {
|
|||
return songs;
|
||||
}
|
||||
|
||||
public void insert(Song song, boolean reset, int afterIndex) {
|
||||
public void insert(Media song, boolean reset, int afterIndex) {
|
||||
try {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
List<Media> songs = new ArrayList<>();
|
||||
|
||||
if (!reset) {
|
||||
GetSongsThreadSafe getSongsThreadSafe = new GetSongsThreadSafe(queueDao);
|
||||
|
|
@ -72,9 +72,9 @@ public class QueueRepository {
|
|||
}
|
||||
}
|
||||
|
||||
public void insertAll(List<Song> toAdd, boolean reset, int afterIndex) {
|
||||
public void insertAll(List<Media> toAdd, boolean reset, int afterIndex) {
|
||||
try {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
List<Media> songs = new ArrayList<>();
|
||||
|
||||
if (!reset) {
|
||||
GetSongsThreadSafe getSongsThreadSafe = new GetSongsThreadSafe(queueDao);
|
||||
|
|
@ -176,7 +176,7 @@ public class QueueRepository {
|
|||
|
||||
private static class GetSongsThreadSafe implements Runnable {
|
||||
private final QueueDao queueDao;
|
||||
private List<Song> songs;
|
||||
private List<Media> songs;
|
||||
|
||||
public GetSongsThreadSafe(QueueDao queueDao) {
|
||||
this.queueDao = queueDao;
|
||||
|
|
@ -187,16 +187,16 @@ public class QueueRepository {
|
|||
songs = MappingUtil.mapQueue(queueDao.getAllSimple());
|
||||
}
|
||||
|
||||
public List<Song> getSongs() {
|
||||
public List<Media> getSongs() {
|
||||
return songs;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InsertAllThreadSafe implements Runnable {
|
||||
private final QueueDao queueDao;
|
||||
private final List<Song> songs;
|
||||
private final List<Media> songs;
|
||||
|
||||
public InsertAllThreadSafe(QueueDao queueDao, List<Song> songs) {
|
||||
public InsertAllThreadSafe(QueueDao queueDao, List<Media> songs) {
|
||||
this.queueDao = queueDao;
|
||||
this.songs = songs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import com.cappielloantonio.play.database.dao.RecentSearchDao;
|
|||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.RecentSearch;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumID3;
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistID3;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
|
|
@ -37,8 +37,8 @@ public class SearchingRepository {
|
|||
recentSearchDao = database.recentSearchDao();
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getSearchedSongs(String query) {
|
||||
MutableLiveData<List<Song>> searchedSongs = new MutableLiveData<>();
|
||||
public MutableLiveData<List<Media>> getSearchedSongs(String query) {
|
||||
MutableLiveData<List<Media>> searchedSongs = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getSearchingClient()
|
||||
|
|
@ -46,7 +46,7 @@ public class SearchingRepository {
|
|||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
List<Media> songs = new ArrayList<>();
|
||||
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getSearchResult3() != null) {
|
||||
songs.addAll(MappingUtil.mapSong(response.body().getSearchResult3().getSongs()));
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
||||
|
|
@ -29,8 +29,8 @@ public class SongRepository {
|
|||
this.application = application;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getStarredSongs(boolean random, int size) {
|
||||
MutableLiveData<List<Song>> starredSongs = new MutableLiveData<>();
|
||||
public MutableLiveData<List<Media>> getStarredSongs(boolean random, int size) {
|
||||
MutableLiveData<List<Media>> starredSongs = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getAlbumSongListClient()
|
||||
|
|
@ -39,7 +39,7 @@ public class SongRepository {
|
|||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getStarred2() != null) {
|
||||
List<Song> songs = new ArrayList<>(MappingUtil.mapSong(response.body().getStarred2().getSongs()));
|
||||
List<Media> songs = new ArrayList<>(MappingUtil.mapSong(response.body().getStarred2().getSongs()));
|
||||
|
||||
if (!random) {
|
||||
starredSongs.setValue(songs);
|
||||
|
|
@ -59,7 +59,7 @@ public class SongRepository {
|
|||
return starredSongs;
|
||||
}
|
||||
|
||||
public void getInstantMix(Song song, int count, MediaCallback callback) {
|
||||
public void getInstantMix(Media song, int count, MediaCallback callback) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
.getSimilarSongs2(song.getId(), count)
|
||||
|
|
@ -67,7 +67,7 @@ public class SongRepository {
|
|||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getSimilarSongs2() != null) {
|
||||
List<Song> songs = new ArrayList<>(MappingUtil.mapSong(response.body().getSimilarSongs2().getSongs()));
|
||||
List<Media> songs = new ArrayList<>(MappingUtil.mapSong(response.body().getSimilarSongs2().getSongs()));
|
||||
|
||||
if (songs.size() <= 1) {
|
||||
songs.add(song);
|
||||
|
|
@ -79,15 +79,15 @@ public class SongRepository {
|
|||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<SubsonicResponse> call, @NonNull Throwable t) {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
List<Media> songs = new ArrayList<>();
|
||||
songs.add(song);
|
||||
callback.onLoadMedia(songs);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getRandomSample(int number, Integer fromYear, Integer toYear) {
|
||||
MutableLiveData<List<Song>> randomSongsSample = new MutableLiveData<>();
|
||||
public MutableLiveData<List<Media>> getRandomSample(int number, Integer fromYear, Integer toYear) {
|
||||
MutableLiveData<List<Media>> randomSongsSample = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getAlbumSongListClient()
|
||||
|
|
@ -95,7 +95,7 @@ public class SongRepository {
|
|||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
List<Media> songs = new ArrayList<>();
|
||||
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getRandomSongs() != null) {
|
||||
songs.addAll(MappingUtil.mapSong(response.body().getRandomSongs().getSongs()));
|
||||
|
|
@ -181,8 +181,8 @@ public class SongRepository {
|
|||
});
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getSongsByGenre(String id) {
|
||||
MutableLiveData<List<Song>> songsByGenre = new MutableLiveData<>();
|
||||
public MutableLiveData<List<Media>> getSongsByGenre(String id) {
|
||||
MutableLiveData<List<Media>> songsByGenre = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getAlbumSongListClient()
|
||||
|
|
@ -191,15 +191,15 @@ public class SongRepository {
|
|||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getSongsByGenre() != null) {
|
||||
List<Song> newSongs = new ArrayList<>(MappingUtil.mapSong(response.body().getSongsByGenre().getSongs()));
|
||||
List<Song> songs = songsByGenre.getValue();
|
||||
List<Media> newSongs = new ArrayList<>(MappingUtil.mapSong(response.body().getSongsByGenre().getSongs()));
|
||||
List<Media> songs = songsByGenre.getValue();
|
||||
|
||||
if (songs == null) songs = new ArrayList<>();
|
||||
songs.addAll(newSongs);
|
||||
Collections.shuffle(songs);
|
||||
|
||||
LinkedHashSet<Song> hashSet = new LinkedHashSet<>(songs);
|
||||
ArrayList<Song> songsWithoutDuplicates = new ArrayList<>(hashSet);
|
||||
LinkedHashSet<Media> hashSet = new LinkedHashSet<>(songs);
|
||||
ArrayList<Media> songsWithoutDuplicates = new ArrayList<>(hashSet);
|
||||
|
||||
songsByGenre.setValue(songsWithoutDuplicates);
|
||||
}
|
||||
|
|
@ -214,8 +214,8 @@ public class SongRepository {
|
|||
return songsByGenre;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getSongsByGenres(ArrayList<String> genresId) {
|
||||
MutableLiveData<List<Song>> songsByGenre = new MutableLiveData<>();
|
||||
public MutableLiveData<List<Media>> getSongsByGenres(ArrayList<String> genresId) {
|
||||
MutableLiveData<List<Media>> songsByGenre = new MutableLiveData<>();
|
||||
|
||||
for (String id : genresId)
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
|
|
@ -224,7 +224,7 @@ public class SongRepository {
|
|||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
List<Media> songs = new ArrayList<>();
|
||||
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getSongsByGenre() != null) {
|
||||
songs.addAll(MappingUtil.mapSong(response.body().getSongsByGenre().getSongs()));
|
||||
|
|
@ -242,8 +242,8 @@ public class SongRepository {
|
|||
return songsByGenre;
|
||||
}
|
||||
|
||||
public MutableLiveData<Song> getSong(String id) {
|
||||
MutableLiveData<Song> song = new MutableLiveData<>();
|
||||
public MutableLiveData<Media> getSong(String id) {
|
||||
MutableLiveData<Media> song = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
|
|
@ -265,7 +265,7 @@ public class SongRepository {
|
|||
return song;
|
||||
}
|
||||
|
||||
public MutableLiveData<String> getSongLyrics(Song song) {
|
||||
public MutableLiveData<String> getSongLyrics(Media song) {
|
||||
MutableLiveData<String> lyrics = new MutableLiveData<>(null);
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import androidx.media3.session.MediaBrowser;
|
|||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.interfaces.MediaIndexCallback;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
|
@ -64,7 +64,7 @@ public class MediaManager {
|
|||
try {
|
||||
if (mediaBrowserListenableFuture.isDone()) {
|
||||
if (mediaBrowserListenableFuture.get().getMediaItemCount() < 1) {
|
||||
List<Song> songs = getQueueRepository().getSongs();
|
||||
List<Media> songs = getQueueRepository().getSongs();
|
||||
if (songs != null && songs.size() >= 1) {
|
||||
init(mediaBrowserListenableFuture, context, songs);
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ public class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void init(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, List<Song> songs) {
|
||||
public static void init(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, List<Media> songs) {
|
||||
if (mediaBrowserListenableFuture != null) {
|
||||
mediaBrowserListenableFuture.addListener(() -> {
|
||||
try {
|
||||
|
|
@ -164,7 +164,7 @@ public class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void startQueue(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, List<Song> songs, int startIndex) {
|
||||
public static void startQueue(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, List<Media> songs, int startIndex) {
|
||||
if (mediaBrowserListenableFuture != null) {
|
||||
mediaBrowserListenableFuture.addListener(() -> {
|
||||
try {
|
||||
|
|
@ -183,7 +183,7 @@ public class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void startQueue(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, Song song) {
|
||||
public static void startQueue(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, Media song) {
|
||||
if (mediaBrowserListenableFuture != null) {
|
||||
mediaBrowserListenableFuture.addListener(() -> {
|
||||
try {
|
||||
|
|
@ -201,7 +201,7 @@ public class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void enqueue(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, List<Song> songs, boolean playImmediatelyAfter) {
|
||||
public static void enqueue(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, List<Media> songs, boolean playImmediatelyAfter) {
|
||||
if (mediaBrowserListenableFuture != null) {
|
||||
mediaBrowserListenableFuture.addListener(() -> {
|
||||
try {
|
||||
|
|
@ -221,7 +221,7 @@ public class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void enqueue(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, Song song, boolean playImmediatelyAfter) {
|
||||
public static void enqueue(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, Context context, Media song, boolean playImmediatelyAfter) {
|
||||
if (mediaBrowserListenableFuture != null) {
|
||||
mediaBrowserListenableFuture.addListener(() -> {
|
||||
try {
|
||||
|
|
@ -241,7 +241,7 @@ public class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void swap(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, List<Song> songs, int from, int to) {
|
||||
public static void swap(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, List<Media> songs, int from, int to) {
|
||||
if (mediaBrowserListenableFuture != null) {
|
||||
mediaBrowserListenableFuture.addListener(() -> {
|
||||
try {
|
||||
|
|
@ -256,7 +256,7 @@ public class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void remove(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, List<Song> songs, int toRemove) {
|
||||
public static void remove(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, List<Media> songs, int toRemove) {
|
||||
if (mediaBrowserListenableFuture != null) {
|
||||
mediaBrowserListenableFuture.addListener(() -> {
|
||||
try {
|
||||
|
|
@ -312,19 +312,19 @@ public class MediaManager {
|
|||
return new SongRepository(App.getInstance());
|
||||
}
|
||||
|
||||
private static void enqueueDatabase(List<Song> songs, boolean reset, int afterIndex) {
|
||||
private static void enqueueDatabase(List<Media> songs, boolean reset, int afterIndex) {
|
||||
getQueueRepository().insertAll(songs, reset, afterIndex);
|
||||
}
|
||||
|
||||
private static void enqueueDatabase(Song song, boolean reset, int afterIndex) {
|
||||
private static void enqueueDatabase(Media song, boolean reset, int afterIndex) {
|
||||
getQueueRepository().insert(song, reset, afterIndex);
|
||||
}
|
||||
|
||||
private static void swapDatabase(List<Song> songs) {
|
||||
private static void swapDatabase(List<Media> songs) {
|
||||
getQueueRepository().insertAll(songs, true, 0);
|
||||
}
|
||||
|
||||
private static void removeDatabase(List<Song> songs, int toRemove) {
|
||||
private static void removeDatabase(List<Media> songs, int toRemove) {
|
||||
if (toRemove != -1) {
|
||||
songs.remove(toRemove);
|
||||
getQueueRepository().insertAll(songs, true, 0);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ package com.cappielloantonio.play.ui.fragment;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BlendMode;
|
||||
import android.graphics.BlendModeColorFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
|
@ -14,7 +12,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.media3.session.MediaBrowser;
|
||||
|
|
@ -30,7 +27,7 @@ import com.cappielloantonio.play.databinding.FragmentArtistPageBinding;
|
|||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.helper.recyclerview.CustomLinearSnapHelper;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
|
|
@ -41,7 +38,6 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ArtistPageFragment extends Fragment {
|
||||
private static final String TAG = "ArtistPageFragment";
|
||||
|
|
@ -102,7 +98,7 @@ public class ArtistPageFragment extends Fragment {
|
|||
|
||||
bind.mostStreamedSongTextViewClickable.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.BY_ARTIST, Song.BY_ARTIST);
|
||||
bundle.putString(Media.BY_ARTIST, Media.BY_ARTIST);
|
||||
bundle.putParcelable("artist_object", artistPageViewModel.getArtist());
|
||||
activity.navController.navigate(R.id.action_artistPageFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
|
@ -170,7 +166,7 @@ public class ArtistPageFragment extends Fragment {
|
|||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
if (media.size() > 0) {
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), (ArrayList<Song>) media, 0);
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), (ArrayList<Media>) media, 0);
|
||||
activity.setBottomSheetInPeek(true);
|
||||
} else {
|
||||
Toast.makeText(requireContext(), getString(R.string.artist_error_retrieving_radio), Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import android.view.ViewGroup;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.media3.session.MediaBrowser;
|
||||
|
|
@ -21,12 +20,10 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
import androidx.recyclerview.widget.SnapHelper;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.AlbumHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.ArtistHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentDownloadBinding;
|
||||
|
|
@ -34,7 +31,7 @@ import com.cappielloantonio.play.helper.recyclerview.DotsIndicatorDecoration;
|
|||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.UIUtil;
|
||||
|
|
@ -153,7 +150,7 @@ public class DownloadFragment extends Fragment {
|
|||
|
||||
bind.downloadedTracksTextViewClickable.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.DOWNLOADED, Song.DOWNLOADED);
|
||||
bundle.putString(Media.DOWNLOADED, Media.DOWNLOADED);
|
||||
activity.navController.navigate(R.id.action_downloadFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import androidx.lifecycle.ViewModelProvider;
|
|||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.databinding.FragmentFilterBinding;
|
||||
import com.cappielloantonio.play.model.Genre;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.viewmodel.FilterViewModel;
|
||||
|
|
@ -57,7 +57,7 @@ public class FilterFragment extends Fragment {
|
|||
|
||||
private void init() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.BY_GENRES, Song.BY_GENRES);
|
||||
bundle.putString(Media.BY_GENRES, Media.BY_GENRES);
|
||||
bundle.putStringArrayList("filters_list", filterViewModel.getFilters());
|
||||
bundle.putStringArrayList("filter_name_list", filterViewModel.getFilterNames());
|
||||
bind.finishFilteringTextViewClickable.setOnClickListener(v -> {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import com.cappielloantonio.play.R;
|
|||
import com.cappielloantonio.play.adapter.GenreCatalogueAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentGenreCatalogueBinding;
|
||||
import com.cappielloantonio.play.helper.recyclerview.GridItemDecoration;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.viewmodel.GenreCatalogueViewModel;
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ public class GenreCatalogueFragment extends Fragment {
|
|||
bind.genreCatalogueRecyclerView.setAdapter(genreCatalogueAdapter);
|
||||
genreCatalogueAdapter.setClickListener((view, position) -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.BY_GENRE, Song.BY_GENRE);
|
||||
bundle.putString(Media.BY_GENRE, Media.BY_GENRE);
|
||||
bundle.putParcelable("genre_object", genreCatalogueAdapter.getItem(position));
|
||||
activity.navController.navigate(R.id.action_genreCatalogueFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.cappielloantonio.play.ui.fragment;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.ComponentName;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
|
@ -42,7 +41,7 @@ import com.cappielloantonio.play.helper.recyclerview.DotsIndicatorDecoration;
|
|||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
|
|
@ -181,7 +180,7 @@ public class HomeFragment extends Fragment {
|
|||
|
||||
bind.starredTracksTextViewClickable.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.STARRED, Song.STARRED);
|
||||
bundle.putString(Media.STARRED, Media.STARRED);
|
||||
activity.navController.navigate(R.id.action_homeFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
||||
|
|
@ -451,7 +450,7 @@ public class HomeFragment extends Fragment {
|
|||
yearAdapter = new YearAdapter(requireContext());
|
||||
yearAdapter.setClickListener((view, position) -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.BY_YEAR, Song.BY_YEAR);
|
||||
bundle.putString(Media.BY_YEAR, Media.BY_YEAR);
|
||||
bundle.putInt("year_object", yearAdapter.getItem(position));
|
||||
activity.navController.navigate(R.id.action_homeFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,32 +10,21 @@ import android.view.ViewGroup;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||
import androidx.recyclerview.widget.SnapHelper;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.AlbumAdapter;
|
||||
import com.cappielloantonio.play.adapter.AlbumHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.ArtistAdapter;
|
||||
import com.cappielloantonio.play.adapter.GenreAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistDialogHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.PlaylistHorizontalAdapter;
|
||||
import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentLibraryBinding;
|
||||
import com.cappielloantonio.play.helper.recyclerview.CustomLinearSnapHelper;
|
||||
import com.cappielloantonio.play.helper.recyclerview.DotsIndicatorDecoration;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.UIUtil;
|
||||
import com.cappielloantonio.play.viewmodel.LibraryViewModel;
|
||||
import com.google.android.gms.cast.framework.CastButtonFactory;
|
||||
|
||||
|
|
@ -201,7 +190,7 @@ public class LibraryFragment extends Fragment {
|
|||
genreAdapter = new GenreAdapter(requireContext());
|
||||
genreAdapter.setClickListener((view, position) -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.BY_GENRE, Song.BY_GENRE);
|
||||
bundle.putString(Media.BY_GENRE, Media.BY_GENRE);
|
||||
bundle.putParcelable("genre_object", genreAdapter.getItem(position));
|
||||
activity.navController.navigate(R.id.action_libraryFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.cappielloantonio.play.App;
|
|||
import com.cappielloantonio.play.databinding.InnerFragmentPlayerCoverBinding;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
|
|
@ -121,7 +121,7 @@ public class PlayerCoverFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), (List<Song>) media, true);
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), (List<Media>) media, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.adapter.SongHorizontalAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentSongListPageBinding;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
|
|
@ -80,50 +80,50 @@ public class SongListPageFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void init() {
|
||||
if (requireArguments().getString(Song.RECENTLY_PLAYED) != null) {
|
||||
songListPageViewModel.title = Song.RECENTLY_PLAYED;
|
||||
if (requireArguments().getString(Media.RECENTLY_PLAYED) != null) {
|
||||
songListPageViewModel.title = Media.RECENTLY_PLAYED;
|
||||
songListPageViewModel.toolbarTitle = getString(R.string.song_list_page_recently_played);
|
||||
bind.pageTitleLabel.setText(R.string.song_list_page_recently_played);
|
||||
} else if (requireArguments().getString(Song.MOST_PLAYED) != null) {
|
||||
songListPageViewModel.title = Song.MOST_PLAYED;
|
||||
} else if (requireArguments().getString(Media.MOST_PLAYED) != null) {
|
||||
songListPageViewModel.title = Media.MOST_PLAYED;
|
||||
songListPageViewModel.toolbarTitle = getString(R.string.song_list_page_most_played);
|
||||
bind.pageTitleLabel.setText(R.string.song_list_page_most_played);
|
||||
} else if (requireArguments().getString(Song.RECENTLY_ADDED) != null) {
|
||||
songListPageViewModel.title = Song.RECENTLY_ADDED;
|
||||
} else if (requireArguments().getString(Media.RECENTLY_ADDED) != null) {
|
||||
songListPageViewModel.title = Media.RECENTLY_ADDED;
|
||||
songListPageViewModel.toolbarTitle = getString(R.string.song_list_page_recently_added);
|
||||
bind.pageTitleLabel.setText(R.string.song_list_page_recently_added);
|
||||
} else if (requireArguments().getString(Song.BY_GENRE) != null) {
|
||||
songListPageViewModel.title = Song.BY_GENRE;
|
||||
} else if (requireArguments().getString(Media.BY_GENRE) != null) {
|
||||
songListPageViewModel.title = Media.BY_GENRE;
|
||||
songListPageViewModel.genre = requireArguments().getParcelable("genre_object");
|
||||
songListPageViewModel.toolbarTitle = MusicUtil.getReadableString(songListPageViewModel.genre.getName());
|
||||
bind.pageTitleLabel.setText(MusicUtil.getReadableString(songListPageViewModel.genre.getName()));
|
||||
} else if (requireArguments().getString(Song.BY_ARTIST) != null) {
|
||||
songListPageViewModel.title = Song.BY_ARTIST;
|
||||
} else if (requireArguments().getString(Media.BY_ARTIST) != null) {
|
||||
songListPageViewModel.title = Media.BY_ARTIST;
|
||||
songListPageViewModel.artist = requireArguments().getParcelable("artist_object");
|
||||
songListPageViewModel.toolbarTitle = getString(R.string.song_list_page_top, MusicUtil.getReadableString(songListPageViewModel.artist.getName()));
|
||||
bind.pageTitleLabel.setText(getString(R.string.song_list_page_top, MusicUtil.getReadableString(songListPageViewModel.artist.getName())));
|
||||
} else if (requireArguments().getString(Song.BY_GENRES) != null) {
|
||||
songListPageViewModel.title = Song.BY_GENRES;
|
||||
} else if (requireArguments().getString(Media.BY_GENRES) != null) {
|
||||
songListPageViewModel.title = Media.BY_GENRES;
|
||||
songListPageViewModel.filters = requireArguments().getStringArrayList("filters_list");
|
||||
songListPageViewModel.filterNames = requireArguments().getStringArrayList("filter_name_list");
|
||||
songListPageViewModel.toolbarTitle = songListPageViewModel.getFiltersTitle();
|
||||
bind.pageTitleLabel.setText(songListPageViewModel.getFiltersTitle());
|
||||
} else if (requireArguments().getString(Song.BY_YEAR) != null) {
|
||||
songListPageViewModel.title = Song.BY_YEAR;
|
||||
} else if (requireArguments().getString(Media.BY_YEAR) != null) {
|
||||
songListPageViewModel.title = Media.BY_YEAR;
|
||||
songListPageViewModel.year = requireArguments().getInt("year_object");
|
||||
songListPageViewModel.toolbarTitle = getString(R.string.song_list_page_year, songListPageViewModel.year);
|
||||
bind.pageTitleLabel.setText(getString(R.string.song_list_page_year, songListPageViewModel.year));
|
||||
} else if (requireArguments().getString(Song.STARRED) != null) {
|
||||
songListPageViewModel.title = Song.STARRED;
|
||||
} else if (requireArguments().getString(Media.STARRED) != null) {
|
||||
songListPageViewModel.title = Media.STARRED;
|
||||
songListPageViewModel.toolbarTitle = getString(R.string.song_list_page_starred);
|
||||
bind.pageTitleLabel.setText(R.string.song_list_page_starred);
|
||||
} else if (requireArguments().getString(Song.DOWNLOADED) != null) {
|
||||
songListPageViewModel.title = Song.DOWNLOADED;
|
||||
} else if (requireArguments().getString(Media.DOWNLOADED) != null) {
|
||||
songListPageViewModel.title = Media.DOWNLOADED;
|
||||
songListPageViewModel.toolbarTitle = getString(R.string.song_list_page_downloaded);
|
||||
bind.pageTitleLabel.setText(getString(R.string.song_list_page_downloaded));
|
||||
} else if (requireArguments().getParcelable("album_object") != null) {
|
||||
songListPageViewModel.album = requireArguments().getParcelable("album_object");
|
||||
songListPageViewModel.title = Song.FROM_ALBUM;
|
||||
songListPageViewModel.title = Media.FROM_ALBUM;
|
||||
songListPageViewModel.toolbarTitle = MusicUtil.getReadableString(songListPageViewModel.album.getTitle());
|
||||
bind.pageTitleLabel.setText(MusicUtil.getReadableString(songListPageViewModel.album.getTitle()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import com.cappielloantonio.play.glide.CustomGlideRequest;
|
|||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Download;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
|
|
@ -113,7 +113,7 @@ public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
if (media.size() > 0) {
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), (ArrayList<Song>) media, 0);
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), (ArrayList<Media>) media, 0);
|
||||
((MainActivity) requireActivity()).setBottomSheetInPeek(true);
|
||||
} else {
|
||||
Toast.makeText(requireContext(), getString(R.string.album_error_retrieving_radio), Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import com.cappielloantonio.play.R;
|
|||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
|
|
@ -104,7 +104,7 @@ public class ArtistBottomSheetDialog extends BottomSheetDialogFragment implement
|
|||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
if (media.size() > 0) {
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), (ArrayList<Song>) media, 0);
|
||||
MediaManager.startQueue(mediaBrowserListenableFuture, requireContext(), (ArrayList<Media>) media, 0);
|
||||
((MainActivity) requireActivity()).setBottomSheetInPeek(true);
|
||||
} else {
|
||||
Toast.makeText(requireContext(), getString(R.string.artist_error_retrieving_radio), Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import com.cappielloantonio.play.App;
|
|||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.service.MediaManager;
|
||||
import com.cappielloantonio.play.service.MediaService;
|
||||
|
|
@ -43,7 +43,7 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
private static final String TAG = "SongBottomSheetDialog";
|
||||
|
||||
private SongBottomSheetViewModel songBottomSheetViewModel;
|
||||
private Song song;
|
||||
private Media song;
|
||||
|
||||
private ListenableFuture<MediaBrowser> mediaBrowserListenableFuture;
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
|||
|
||||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), (List<Song>) media, true);
|
||||
MediaManager.enqueue(mediaBrowserListenableFuture, requireContext(), (List<Media>) media, true);
|
||||
dismissBottomSheet();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import com.cappielloantonio.play.model.Playlist;
|
|||
import com.cappielloantonio.play.model.PodcastChannel;
|
||||
import com.cappielloantonio.play.model.PodcastEpisode;
|
||||
import com.cappielloantonio.play.model.Queue;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumID3;
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumInfo;
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3;
|
||||
|
|
@ -30,18 +30,18 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class MappingUtil {
|
||||
public static ArrayList<Song> mapSong(List<Child> children) {
|
||||
ArrayList<Song> songs = new ArrayList();
|
||||
public static ArrayList<Media> mapSong(List<Child> children) {
|
||||
ArrayList<Media> songs = new ArrayList();
|
||||
|
||||
for (Child child : children) {
|
||||
songs.add(new Song(child));
|
||||
songs.add(new Media(child));
|
||||
}
|
||||
|
||||
return songs;
|
||||
}
|
||||
|
||||
public static Song mapSong(Child child) {
|
||||
return new Song(child);
|
||||
public static Media mapSong(Child child) {
|
||||
return new Media(child);
|
||||
}
|
||||
|
||||
public static ArrayList<Album> mapAlbum(List<AlbumID3> albumID3List) {
|
||||
|
|
@ -94,21 +94,21 @@ public class MappingUtil {
|
|||
return artists;
|
||||
}
|
||||
|
||||
public static ArrayList<Song> mapQueue(List<Queue> queueList) {
|
||||
ArrayList<Song> songs = new ArrayList();
|
||||
public static ArrayList<Media> mapQueue(List<Queue> queueList) {
|
||||
ArrayList<Media> songs = new ArrayList();
|
||||
|
||||
for (Queue item : queueList) {
|
||||
songs.add(new Song(item));
|
||||
songs.add(new Media(item));
|
||||
}
|
||||
|
||||
return songs;
|
||||
}
|
||||
|
||||
public static Queue mapSongToQueue(Song song, int trackOrder) {
|
||||
public static Queue mapSongToQueue(Media song, int trackOrder) {
|
||||
return new Queue(trackOrder, song.getId(), song.getTitle(), song.getAlbumId(), song.getAlbumName(), song.getArtistId(), song.getArtistName(), song.getPrimary(), song.getDuration(), 0, 0);
|
||||
}
|
||||
|
||||
public static List<Queue> mapSongsToQueue(List<Song> songs) {
|
||||
public static List<Queue> mapSongsToQueue(List<Media> songs) {
|
||||
List<Queue> queue = new ArrayList<>();
|
||||
|
||||
for (int counter = 0; counter < songs.size(); counter++) {
|
||||
|
|
@ -128,11 +128,11 @@ public class MappingUtil {
|
|||
return playlist;
|
||||
}
|
||||
|
||||
public static ArrayList<Song> mapDownloadToSong(List<Download> downloads) {
|
||||
ArrayList<Song> songs = new ArrayList();
|
||||
public static ArrayList<Media> mapDownloadToSong(List<Download> downloads) {
|
||||
ArrayList<Media> songs = new ArrayList();
|
||||
|
||||
for (Download download : downloads) {
|
||||
Song song = new Song(download);
|
||||
Media song = new Media(download);
|
||||
if (!songs.contains(song)) {
|
||||
songs.add(song);
|
||||
}
|
||||
|
|
@ -177,17 +177,17 @@ public class MappingUtil {
|
|||
return playlists;
|
||||
}
|
||||
|
||||
public static ArrayList<Download> mapDownload(List<Song> songs, String playlistId, String playlistName) {
|
||||
public static ArrayList<Download> mapDownload(List<Media> songs, String playlistId, String playlistName) {
|
||||
ArrayList<Download> downloads = new ArrayList();
|
||||
|
||||
for (Song song : songs) {
|
||||
for (Media song : songs) {
|
||||
downloads.add(new Download(song, playlistId, playlistName));
|
||||
}
|
||||
|
||||
return downloads;
|
||||
}
|
||||
|
||||
public static Download mapDownload(Song song, String playlistId, String playlistName) {
|
||||
public static Download mapDownload(Media song, String playlistId, String playlistName) {
|
||||
return new Download(song, playlistId, playlistName);
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ public class MappingUtil {
|
|||
}
|
||||
|
||||
@SuppressLint("UnsafeOptInUsageError")
|
||||
public static MediaItem mapMediaItem(Context context, Song song, boolean stream) {
|
||||
public static MediaItem mapMediaItem(Context context, Media song, boolean stream) {
|
||||
boolean isDownloaded = DownloadUtil.getDownloadTracker(context).isDownloaded(MusicUtil.getDownloadUri(song.getId()));
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
|
@ -258,8 +258,8 @@ public class MappingUtil {
|
|||
ArrayList<MediaItem> mediaItems = new ArrayList();
|
||||
|
||||
for(int i = 0; i < items.size(); i++) {
|
||||
if(items.get(i) instanceof Song) {
|
||||
mediaItems.add(mapMediaItem(context, (Song) items.get(i), stream));
|
||||
if(items.get(i) instanceof Media) {
|
||||
mediaItems.add(mapMediaItem(context, (Media) items.get(i), stream));
|
||||
}
|
||||
|
||||
if(items.get(i) instanceof PodcastEpisode) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import android.util.Log;
|
|||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.glide.CustomGlideRequest;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class AlbumBottomSheetViewModel extends AndroidViewModel {
|
|||
return artistRepository.getArtist(album.getArtistId());
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getAlbumTracks() {
|
||||
public MutableLiveData<List<Media>> getAlbumTracks() {
|
||||
return albumRepository.getAlbumTracks(album.getId());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.cappielloantonio.play.viewmodel;
|
|||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
|
@ -11,7 +10,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.DownloadRepository;
|
||||
|
|
@ -24,7 +23,7 @@ public class AlbumPageViewModel extends AndroidViewModel {
|
|||
private final ArtistRepository artistRepository;
|
||||
private final DownloadRepository downloadRepository;
|
||||
|
||||
private MutableLiveData<List<Song>> songLiveList = new MutableLiveData<>();
|
||||
private MutableLiveData<List<Media>> songLiveList = new MutableLiveData<>();
|
||||
|
||||
private Album album;
|
||||
private boolean isOffline;
|
||||
|
|
@ -37,7 +36,7 @@ public class AlbumPageViewModel extends AndroidViewModel {
|
|||
downloadRepository = new DownloadRepository(application);
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getAlbumSongLiveList(LifecycleOwner owner) {
|
||||
public LiveData<List<Media>> getAlbumSongLiveList(LifecycleOwner owner) {
|
||||
if (isOffline) {
|
||||
downloadRepository.getLiveDownloadFromAlbum(album.getId()).observe(owner, downloads -> songLiveList.postValue(MappingUtil.mapDownloadToSong(downloads)));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import androidx.lifecycle.LiveData;
|
|||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ public class ArtistPageViewModel extends AndroidViewModel {
|
|||
return artistRepository.getArtistFullInfo(id);
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getArtistTopSongList(int count) {
|
||||
public LiveData<List<Media>> getArtistTopSongList(int count) {
|
||||
return artistRepository.getTopSongs(artist.getName(), count);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.DownloadRepository;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ public class DownloadViewModel extends AndroidViewModel {
|
|||
|
||||
private final MutableLiveData<List<Artist>> downloadedArtistSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Album>> downloadedAlbumSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Song>> downloadedTrackSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Media>> downloadedTrackSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Playlist>> downloadedPlaylistSample = new MutableLiveData<>(null);
|
||||
|
||||
public DownloadViewModel(@NonNull Application application) {
|
||||
|
|
@ -43,7 +43,7 @@ public class DownloadViewModel extends AndroidViewModel {
|
|||
return downloadedAlbumSample;
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getDownloadedTracks(LifecycleOwner owner, int size) {
|
||||
public LiveData<List<Media>> getDownloadedTracks(LifecycleOwner owner, int size) {
|
||||
downloadRepository.getLiveDownloadSample(size, false, false, true, false).observe(owner, downloads -> downloadedTrackSample.postValue(MappingUtil.mapDownloadToSong(downloads)));
|
||||
return downloadedTrackSample;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,12 @@ import com.cappielloantonio.play.model.Album;
|
|||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.PodcastEpisode;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.PlaylistRepository;
|
||||
import com.cappielloantonio.play.repository.PodcastRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.subsonic.models.NewestPodcasts;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
|
@ -36,11 +35,11 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
private final PlaylistRepository playlistRepository;
|
||||
private final PodcastRepository podcastRepository;
|
||||
|
||||
private final MutableLiveData<List<Song>> dicoverSongSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Media>> dicoverSongSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Album>> newReleasedAlbum = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Song>> starredTracksSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Media>> starredTracksSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Artist>> starredArtistsSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Song>> starredTracks = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Media>> starredTracks = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Album>> starredAlbums = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Artist>> starredArtists = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Album>> mostPlayedAlbumSample = new MutableLiveData<>(null);
|
||||
|
|
@ -64,7 +63,7 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
artistRepository.getStarredArtists(true, 10).observeForever(starredArtistsSample::postValue);
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getDiscoverSongSample() {
|
||||
public LiveData<List<Media>> getDiscoverSongSample() {
|
||||
return dicoverSongSample;
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +78,7 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
return newReleasedAlbum;
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getStarredTracksSample() {
|
||||
public LiveData<List<Media>> getStarredTracksSample() {
|
||||
return starredTracksSample;
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +86,7 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
return starredArtistsSample;
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getStarredTracks(LifecycleOwner owner) {
|
||||
public LiveData<List<Media>> getStarredTracks(LifecycleOwner owner) {
|
||||
songRepository.getStarredSongs(true, 20).observe(owner, starredTracks::postValue);
|
||||
return starredTracks;
|
||||
}
|
||||
|
|
@ -131,7 +130,7 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
return pinnedPlaylists;
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getPlaylistSongLiveList(String playlistId) {
|
||||
public LiveData<List<Media>> getPlaylistSongLiveList(String playlistId) {
|
||||
return playlistRepository.getPlaylistSongs(playlistId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Queue;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
|
@ -31,7 +31,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||
|
||||
private final MutableLiveData<String> lyricsLiveData = new MutableLiveData<>(null);
|
||||
|
||||
private final MutableLiveData<Song> liveSong = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<Media> liveSong = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<Album> liveAlbum = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<Artist> liveArtist = new MutableLiveData<>(null);
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||
return queueRepository.getLiveQueue();
|
||||
}
|
||||
|
||||
public void setFavorite(Context context, Song song) {
|
||||
public void setFavorite(Context context, Media song) {
|
||||
if (song != null) {
|
||||
if (song.isFavorite()) {
|
||||
songRepository.unstar(song.getId());
|
||||
|
|
@ -70,11 +70,11 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||
return lyricsLiveData;
|
||||
}
|
||||
|
||||
public void refreshSongInfo(LifecycleOwner owner, Song song) {
|
||||
public void refreshSongInfo(LifecycleOwner owner, Media song) {
|
||||
songRepository.getSongLyrics(song).observe(owner, lyricsLiveData::postValue);
|
||||
}
|
||||
|
||||
public LiveData<Song> getLiveSong() {
|
||||
public LiveData<Media> getLiveSong() {
|
||||
return liveSong;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import androidx.lifecycle.LiveData;
|
|||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.PlaylistRepository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -19,7 +19,7 @@ public class PlaylistChooserViewModel extends AndroidViewModel {
|
|||
private final PlaylistRepository playlistRepository;
|
||||
|
||||
private final MutableLiveData<List<Playlist>> playlists = new MutableLiveData<>(null);
|
||||
private Song toAdd;
|
||||
private Media toAdd;
|
||||
|
||||
public PlaylistChooserViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
|
@ -38,11 +38,11 @@ public class PlaylistChooserViewModel extends AndroidViewModel {
|
|||
playlistRepository.addSongToPlaylist(playlistId, new ArrayList(Collections.singletonList(toAdd.getId())));
|
||||
}
|
||||
|
||||
public void setSongToAdd(Song song) {
|
||||
public void setSongToAdd(Media song) {
|
||||
toAdd = song;
|
||||
}
|
||||
|
||||
public Song getSongToAdd() {
|
||||
public Media getSongToAdd() {
|
||||
return toAdd;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cappielloantonio.play.viewmodel;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
|
|
@ -9,7 +8,7 @@ import androidx.lifecycle.LiveData;
|
|||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.PlaylistRepository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -22,10 +21,10 @@ public class PlaylistEditorViewModel extends AndroidViewModel {
|
|||
|
||||
private final PlaylistRepository playlistRepository;
|
||||
|
||||
private Song toAdd;
|
||||
private Media toAdd;
|
||||
private Playlist toEdit;
|
||||
|
||||
private MutableLiveData<List<Song>> songLiveList = new MutableLiveData<>();
|
||||
private MutableLiveData<List<Media>> songLiveList = new MutableLiveData<>();
|
||||
|
||||
public PlaylistEditorViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
|
@ -46,11 +45,11 @@ public class PlaylistEditorViewModel extends AndroidViewModel {
|
|||
if (toEdit != null) playlistRepository.deletePlaylist(toEdit.getId());
|
||||
}
|
||||
|
||||
public Song getSongToAdd() {
|
||||
public Media getSongToAdd() {
|
||||
return toAdd;
|
||||
}
|
||||
|
||||
public void setSongToAdd(Song song) {
|
||||
public void setSongToAdd(Media song) {
|
||||
this.toAdd = song;
|
||||
}
|
||||
|
||||
|
|
@ -68,26 +67,26 @@ public class PlaylistEditorViewModel extends AndroidViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getPlaylistSongLiveList() {
|
||||
public LiveData<List<Media>> getPlaylistSongLiveList() {
|
||||
return songLiveList;
|
||||
}
|
||||
|
||||
public void removeFromPlaylistSongLiveList(int position) {
|
||||
List<Song> songs = songLiveList.getValue();
|
||||
List<Media> songs = songLiveList.getValue();
|
||||
Objects.requireNonNull(songs).remove(position);
|
||||
songLiveList.postValue(songs);
|
||||
}
|
||||
|
||||
public void orderPlaylistSongLiveListAfterSwap(List<Song> songs) {
|
||||
public void orderPlaylistSongLiveListAfterSwap(List<Media> songs) {
|
||||
songLiveList.postValue(songs);
|
||||
}
|
||||
|
||||
private ArrayList<String> getPlaylistSongIds() {
|
||||
List<Song> songs = songLiveList.getValue();
|
||||
List<Media> songs = songLiveList.getValue();
|
||||
ArrayList<String> ids = new ArrayList<>();
|
||||
|
||||
if (songs != null && !songs.isEmpty()) {
|
||||
for (Song song : songs) {
|
||||
for (Media song : songs) {
|
||||
ids.add(song.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.cappielloantonio.play.viewmodel;
|
|||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
|
@ -11,7 +10,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.DownloadRepository;
|
||||
import com.cappielloantonio.play.repository.PlaylistRepository;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
|
@ -23,7 +22,7 @@ public class PlaylistPageViewModel extends AndroidViewModel {
|
|||
private final PlaylistRepository playlistRepository;
|
||||
private final DownloadRepository downloadRepository;
|
||||
|
||||
private MutableLiveData<List<Song>> playlistSongLiveList = new MutableLiveData<>();
|
||||
private MutableLiveData<List<Media>> playlistSongLiveList = new MutableLiveData<>();
|
||||
|
||||
private Playlist playlist;
|
||||
private boolean isOffline;
|
||||
|
|
@ -35,7 +34,7 @@ public class PlaylistPageViewModel extends AndroidViewModel {
|
|||
downloadRepository = new DownloadRepository(application);
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getPlaylistSongLiveList(LifecycleOwner owner) {
|
||||
public LiveData<List<Media>> getPlaylistSongLiveList(LifecycleOwner owner) {
|
||||
if (isOffline) {
|
||||
downloadRepository.getLiveDownloadFromPlaylist(playlist.getId()).observe(owner, downloads -> playlistSongLiveList.postValue(MappingUtil.mapDownloadToSong(downloads)));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import androidx.lifecycle.LiveData;
|
|||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
|
@ -18,7 +18,7 @@ public class RatingViewModel extends AndroidViewModel {
|
|||
private final AlbumRepository albumRepository;
|
||||
private final ArtistRepository artistRepository;
|
||||
|
||||
private Song song;
|
||||
private Media song;
|
||||
private Album album;
|
||||
private Artist artist;
|
||||
|
||||
|
|
@ -30,15 +30,15 @@ public class RatingViewModel extends AndroidViewModel {
|
|||
artistRepository = new ArtistRepository(application);
|
||||
}
|
||||
|
||||
public Song getSong() {
|
||||
public Media getSong() {
|
||||
return song;
|
||||
}
|
||||
|
||||
public LiveData<Song> getLiveSong() {
|
||||
public LiveData<Media> getLiveSong() {
|
||||
return songRepository.getSong(song.getId());
|
||||
}
|
||||
|
||||
public void setSong(Song song) {
|
||||
public void setSong(Media song) {
|
||||
this.song = song;
|
||||
this.album = null;
|
||||
this.artist = null;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import androidx.lifecycle.LiveData;
|
|||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.RecentSearch;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.SearchingRepository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -40,7 +40,7 @@ public class SearchViewModel extends AndroidViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> searchSong(String title) {
|
||||
public LiveData<List<Media>> searchSong(String title) {
|
||||
return searchingRepository.getSearchedSongs(title);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import androidx.lifecycle.LiveData;
|
|||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
|
@ -22,7 +22,7 @@ public class SongBottomSheetViewModel extends AndroidViewModel {
|
|||
private final AlbumRepository albumRepository;
|
||||
private final ArtistRepository artistRepository;
|
||||
|
||||
private Song song;
|
||||
private Media song;
|
||||
|
||||
public SongBottomSheetViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
|
@ -32,11 +32,11 @@ public class SongBottomSheetViewModel extends AndroidViewModel {
|
|||
artistRepository = new ArtistRepository(application);
|
||||
}
|
||||
|
||||
public Song getSong() {
|
||||
public Media getSong() {
|
||||
return song;
|
||||
}
|
||||
|
||||
public void setSong(Song song) {
|
||||
public void setSong(Media song) {
|
||||
this.song = song;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import android.app.Application;
|
|||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
|
@ -13,7 +12,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Genre;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.DownloadRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
|
@ -33,7 +32,7 @@ public class SongListPageViewModel extends AndroidViewModel {
|
|||
public Artist artist;
|
||||
public Album album;
|
||||
|
||||
private MutableLiveData<List<Song>> songList;
|
||||
private MutableLiveData<List<Media>> songList;
|
||||
|
||||
public ArrayList<String> filters = new ArrayList<>();
|
||||
public ArrayList<String> filterNames = new ArrayList<>();
|
||||
|
|
@ -48,29 +47,29 @@ public class SongListPageViewModel extends AndroidViewModel {
|
|||
downloadRepository = new DownloadRepository(application);
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getSongList(LifecycleOwner owner) {
|
||||
public LiveData<List<Media>> getSongList(LifecycleOwner owner) {
|
||||
songList = new MutableLiveData<>(new ArrayList<>());
|
||||
|
||||
switch (title) {
|
||||
case Song.BY_GENRE:
|
||||
case Media.BY_GENRE:
|
||||
songList = songRepository.getSongsByGenre(genre.getId());
|
||||
break;
|
||||
case Song.BY_ARTIST:
|
||||
case Media.BY_ARTIST:
|
||||
songList = artistRepository.getTopSongs(artist.getName(), 50);
|
||||
break;
|
||||
case Song.BY_GENRES:
|
||||
case Media.BY_GENRES:
|
||||
songList = songRepository.getSongsByGenres(filters);
|
||||
break;
|
||||
case Song.BY_YEAR:
|
||||
case Media.BY_YEAR:
|
||||
songList = songRepository.getRandomSample(500, year, year + 10);
|
||||
break;
|
||||
case Song.STARRED:
|
||||
case Media.STARRED:
|
||||
songList = songRepository.getStarredSongs(false, -1);
|
||||
break;
|
||||
case Song.DOWNLOADED:
|
||||
case Media.DOWNLOADED:
|
||||
downloadRepository.getLiveDownload().observe(owner, downloads -> songList.setValue(MappingUtil.mapDownloadToSong(downloads)));
|
||||
break;
|
||||
case Song.FROM_ALBUM:
|
||||
case Media.FROM_ALBUM:
|
||||
downloadRepository.getLiveDownloadFromAlbum(album.getId()).observe(owner, downloads -> songList.setValue(MappingUtil.mapDownloadToSong(downloads)));
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,19 +8,15 @@ import androidx.lifecycle.LifecycleOwner;
|
|||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.model.Playlist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.PlaylistRepository;
|
||||
import com.cappielloantonio.play.model.Media;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class StarredSyncViewModel extends AndroidViewModel {
|
||||
private final SongRepository songRepository;
|
||||
|
||||
private final MutableLiveData<List<Song>> starredTracks = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Media>> starredTracks = new MutableLiveData<>(null);
|
||||
|
||||
public StarredSyncViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
|
@ -28,7 +24,7 @@ public class StarredSyncViewModel extends AndroidViewModel {
|
|||
songRepository = new SongRepository(application);
|
||||
}
|
||||
|
||||
public LiveData<List<Song>> getStarredTracks(LifecycleOwner owner) {
|
||||
public LiveData<List<Media>> getStarredTracks(LifecycleOwner owner) {
|
||||
songRepository.getStarredSongs(false, -1).observe(owner, starredTracks::postValue);
|
||||
return starredTracks;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue