mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
Add bottomsheet everywhere
This commit is contained in:
parent
01bdbf49b2
commit
9af0afa441
41 changed files with 866 additions and 359 deletions
|
|
@ -0,0 +1,54 @@
|
|||
package com.cappielloantonio.play.viewmodel;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
|
||||
public class SongBottomSheetViewModel extends AndroidViewModel {
|
||||
private SongRepository songRepository;
|
||||
private AlbumRepository albumRepository;
|
||||
private ArtistRepository artistRepository;
|
||||
|
||||
private Song song;
|
||||
|
||||
public SongBottomSheetViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
songRepository = new SongRepository(application);
|
||||
albumRepository = new AlbumRepository(application);
|
||||
artistRepository = new ArtistRepository(application);
|
||||
}
|
||||
|
||||
public void setSong(Song song) {
|
||||
this.song = song;
|
||||
}
|
||||
|
||||
public Song getSong() {
|
||||
return song;
|
||||
}
|
||||
|
||||
public void setFavorite() {
|
||||
if(song.isFavorite())
|
||||
song.setFavorite(false);
|
||||
else
|
||||
song.setFavorite(true);
|
||||
|
||||
songRepository.setFavoriteStatus(song);
|
||||
}
|
||||
|
||||
public Album getAlbum() {
|
||||
return albumRepository.getAlbumByID(song.getAlbumId());
|
||||
}
|
||||
|
||||
public Artist getArtist() {
|
||||
return artistRepository.getArtistByID(song.getArtistId());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue