Deleted fragment for favorite items

This commit is contained in:
CappielloAntonio 2022-01-17 17:31:29 +01:00
parent 681ea32927
commit cba5bf4b75
3 changed files with 0 additions and 508 deletions

View file

@ -1,64 +0,0 @@
package com.cappielloantonio.play.viewmodel;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
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.repository.AlbumRepository;
import com.cappielloantonio.play.repository.ArtistRepository;
import com.cappielloantonio.play.repository.SongRepository;
import java.util.List;
public class StarredViewModel extends AndroidViewModel {
private final SongRepository songRepository;
private final AlbumRepository albumRepository;
private final ArtistRepository artistRepository;
private final MutableLiveData<List<Song>> starredTracks = new MutableLiveData<>(null);
private final MutableLiveData<List<Album>> starredAlbums = new MutableLiveData<>(null);
private final MutableLiveData<List<Artist>> starredArtists = new MutableLiveData<>(null);
public StarredViewModel(@NonNull Application application) {
super(application);
songRepository = new SongRepository(application);
albumRepository = new AlbumRepository(application);
artistRepository = new ArtistRepository(application);
}
public LiveData<List<Song>> getStarredTracks(LifecycleOwner owner) {
songRepository.getStarredSongs(true, 20).observe(owner, starredTracks::postValue);
return starredTracks;
}
public LiveData<List<Album>> getStarredAlbums(LifecycleOwner owner) {
albumRepository.getStarredAlbums(true, 20).observe(owner, starredAlbums::postValue);
return starredAlbums;
}
public LiveData<List<Artist>> getStarredArtists(LifecycleOwner owner) {
artistRepository.getStarredArtists(true, 20).observe(owner, starredArtists::postValue);
return starredArtists;
}
public void refreshStarredTracks(LifecycleOwner owner) {
songRepository.getStarredSongs(true, 20).observe(owner, starredTracks::postValue);
}
public void refreshStarredAlbums(LifecycleOwner owner) {
albumRepository.getStarredAlbums(true, 20).observe(owner, starredAlbums::postValue);
}
public void refreshStarredArtists(LifecycleOwner owner) {
artistRepository.getStarredArtists(true, 20).observe(owner, starredArtists::postValue);
}
}