mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 10:23:33 +00:00
build: change of package name
This commit is contained in:
parent
49afdbe4eb
commit
b76a38cb30
274 changed files with 1981 additions and 2161 deletions
|
|
@ -1,114 +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.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.DirectoryRepository;
|
||||
import com.cappielloantonio.play.repository.GenreRepository;
|
||||
import com.cappielloantonio.play.repository.PlaylistRepository;
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumID3;
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistID3;
|
||||
import com.cappielloantonio.play.subsonic.models.Genre;
|
||||
import com.cappielloantonio.play.subsonic.models.Indexes;
|
||||
import com.cappielloantonio.play.subsonic.models.MusicFolder;
|
||||
import com.cappielloantonio.play.subsonic.models.Playlist;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LibraryViewModel extends AndroidViewModel {
|
||||
private static final String TAG = "LibraryViewModel";
|
||||
|
||||
private final DirectoryRepository directoryRepository;
|
||||
private final AlbumRepository albumRepository;
|
||||
private final ArtistRepository artistRepository;
|
||||
private final GenreRepository genreRepository;
|
||||
private final PlaylistRepository playlistRepository;
|
||||
|
||||
private final MutableLiveData<List<MusicFolder>> musicFolders = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<Indexes> indexes = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Playlist>> playlistSample = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<AlbumID3>> sampleAlbum = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<ArtistID3>> sampleArtist = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Genre>> sampleGenres = new MutableLiveData<>(null);
|
||||
|
||||
public LibraryViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
directoryRepository = new DirectoryRepository();
|
||||
albumRepository = new AlbumRepository();
|
||||
artistRepository = new ArtistRepository();
|
||||
genreRepository = new GenreRepository();
|
||||
playlistRepository = new PlaylistRepository();
|
||||
}
|
||||
|
||||
public LiveData<List<MusicFolder>> getMusicFolders(LifecycleOwner owner) {
|
||||
if (musicFolders.getValue() == null) {
|
||||
directoryRepository.getMusicFolders().observe(owner, musicFolders::postValue);
|
||||
}
|
||||
|
||||
return musicFolders;
|
||||
}
|
||||
|
||||
public LiveData<Indexes> getIndexes(LifecycleOwner owner) {
|
||||
if (indexes.getValue() == null) {
|
||||
directoryRepository.getIndexes("0", null).observe(owner, indexes::postValue);
|
||||
}
|
||||
|
||||
return indexes;
|
||||
}
|
||||
|
||||
public LiveData<List<AlbumID3>> getAlbumSample(LifecycleOwner owner) {
|
||||
if (sampleAlbum.getValue() == null) {
|
||||
albumRepository.getAlbums("random", 10, null, null).observe(owner, sampleAlbum::postValue);
|
||||
}
|
||||
|
||||
return sampleAlbum;
|
||||
}
|
||||
|
||||
public LiveData<List<ArtistID3>> getArtistSample(LifecycleOwner owner) {
|
||||
if (sampleArtist.getValue() == null) {
|
||||
artistRepository.getArtists(true, 10).observe(owner, sampleArtist::postValue);
|
||||
}
|
||||
|
||||
return sampleArtist;
|
||||
}
|
||||
|
||||
public LiveData<List<Genre>> getGenreSample(LifecycleOwner owner) {
|
||||
if (sampleGenres.getValue() == null) {
|
||||
genreRepository.getGenres(true, 15).observe(owner, sampleGenres::postValue);
|
||||
}
|
||||
|
||||
return sampleGenres;
|
||||
}
|
||||
|
||||
public LiveData<List<Playlist>> getPlaylistSample(LifecycleOwner owner) {
|
||||
if (playlistSample.getValue() == null) {
|
||||
playlistRepository.getPlaylists(true, 10).observe(owner, playlistSample::postValue);
|
||||
}
|
||||
|
||||
return playlistSample;
|
||||
}
|
||||
|
||||
public void refreshAlbumSample(LifecycleOwner owner) {
|
||||
albumRepository.getAlbums("random", 10, null, null).observe(owner, sampleAlbum::postValue);
|
||||
}
|
||||
|
||||
public void refreshArtistSample(LifecycleOwner owner) {
|
||||
artistRepository.getArtists(true, 10).observe(owner, sampleArtist::postValue);
|
||||
}
|
||||
|
||||
public void refreshGenreSample(LifecycleOwner owner) {
|
||||
genreRepository.getGenres(true, 15).observe(owner, sampleGenres::postValue);
|
||||
}
|
||||
|
||||
public void refreshPlaylistSample(LifecycleOwner owner) {
|
||||
playlistRepository.getPlaylists(true, 10).observe(owner, playlistSample::postValue);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue