2020-12-05 21:31:12 +01:00
|
|
|
package com.cappielloantonio.play.viewmodel;
|
|
|
|
|
|
|
|
|
|
import android.app.Application;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.lifecycle.AndroidViewModel;
|
|
|
|
|
import androidx.lifecycle.LiveData;
|
|
|
|
|
|
|
|
|
|
import com.cappielloantonio.play.model.Song;
|
|
|
|
|
import com.cappielloantonio.play.repository.QueueRepository;
|
2020-12-08 11:12:44 +01:00
|
|
|
import com.cappielloantonio.play.repository.SongRepository;
|
2020-12-05 21:31:12 +01:00
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
2020-12-08 11:12:44 +01:00
|
|
|
private static final String TAG = "PlayerBottomSheetViewModel";
|
|
|
|
|
private SongRepository songRepository;
|
2020-12-05 21:31:12 +01:00
|
|
|
private QueueRepository queueRepository;
|
|
|
|
|
|
|
|
|
|
private LiveData<List<Song>> queueSong;
|
2020-12-08 11:12:44 +01:00
|
|
|
private Song song;
|
2020-12-05 21:31:12 +01:00
|
|
|
|
|
|
|
|
public PlayerBottomSheetViewModel(@NonNull Application application) {
|
|
|
|
|
super(application);
|
|
|
|
|
|
2020-12-08 11:12:44 +01:00
|
|
|
songRepository = new SongRepository(application);
|
2020-12-05 21:31:12 +01:00
|
|
|
queueRepository = new QueueRepository(application);
|
|
|
|
|
|
|
|
|
|
queueSong = queueRepository.getLiveQueue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LiveData<List<Song>> getQueueSong() {
|
|
|
|
|
return queueSong;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-08 11:12:44 +01:00
|
|
|
public void setNowPlayingSong(Song song) {
|
|
|
|
|
this.song = song;
|
2020-12-05 21:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
2020-12-08 11:12:44 +01:00
|
|
|
public void setFavorite() {
|
2021-04-13 18:13:22 +02:00
|
|
|
song.setFavorite(!song.isFavorite());
|
2020-12-08 11:12:44 +01:00
|
|
|
songRepository.setFavoriteStatus(song);
|
|
|
|
|
}
|
2020-12-05 21:31:12 +01:00
|
|
|
|
2020-12-08 11:12:44 +01:00
|
|
|
public Song getSong() {
|
|
|
|
|
return song;
|
|
|
|
|
}
|
2020-12-05 21:31:12 +01:00
|
|
|
|
2020-12-08 11:12:44 +01:00
|
|
|
public void setSong(Song song) {
|
|
|
|
|
this.song = song;
|
2020-12-05 21:31:12 +01:00
|
|
|
}
|
|
|
|
|
}
|