mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 09:33:33 +00:00
Fix initialization of mutableLiveData in repository
This commit is contained in:
parent
b8822fcda4
commit
8392d01fc5
7 changed files with 15 additions and 12 deletions
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
|
|
@ -8,6 +8,7 @@
|
||||||
<entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.2814814814814815" />
|
<entry key="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.2814814814814815" />
|
||||||
<entry key="app/src/main/res/drawable-v24/ic_shuffle.xml" value="0.28055555555555556" />
|
<entry key="app/src/main/res/drawable-v24/ic_shuffle.xml" value="0.28055555555555556" />
|
||||||
<entry key="app/src/main/res/drawable/dialog_shape.xml" value="0.27685185185185185" />
|
<entry key="app/src/main/res/drawable/dialog_shape.xml" value="0.27685185185185185" />
|
||||||
|
<entry key="app/src/main/res/drawable/ic_arrow_back.xml" value="0.28055555555555556" />
|
||||||
<entry key="app/src/main/res/drawable/ic_close.xml" value="0.27685185185185185" />
|
<entry key="app/src/main/res/drawable/ic_close.xml" value="0.27685185185185185" />
|
||||||
<entry key="app/src/main/res/drawable/ic_done.xml" value="0.28055555555555556" />
|
<entry key="app/src/main/res/drawable/ic_done.xml" value="0.28055555555555556" />
|
||||||
<entry key="app/src/main/res/drawable/ic_download_for_offline.xml" value="0.27685185185185185" />
|
<entry key="app/src/main/res/drawable/ic_download_for_offline.xml" value="0.27685185185185185" />
|
||||||
|
|
@ -40,7 +41,7 @@
|
||||||
<entry key="app/src/main/res/layout/item_home_discovery_placeholder.xml" value="0.3229166666666667" />
|
<entry key="app/src/main/res/layout/item_home_discovery_placeholder.xml" value="0.3229166666666667" />
|
||||||
<entry key="app/src/main/res/layout/item_home_horizontal_placeholder.xml" value="0.3229166666666667" />
|
<entry key="app/src/main/res/layout/item_home_horizontal_placeholder.xml" value="0.3229166666666667" />
|
||||||
<entry key="app/src/main/res/layout/item_home_placeholder.xml" value="0.47191011235955055" />
|
<entry key="app/src/main/res/layout/item_home_placeholder.xml" value="0.47191011235955055" />
|
||||||
<entry key="app/src/main/res/layout/item_home_similar_track.xml" value="0.3229166666666667" />
|
<entry key="app/src/main/res/layout/item_home_similar_track.xml" value="0.7617554858934169" />
|
||||||
<entry key="app/src/main/res/layout/item_home_track.xml" value="0.3229166666666667" />
|
<entry key="app/src/main/res/layout/item_home_track.xml" value="0.3229166666666667" />
|
||||||
<entry key="app/src/main/res/layout/item_home_year.xml" value="0.3229166666666667" />
|
<entry key="app/src/main/res/layout/item_home_year.xml" value="0.3229166666666667" />
|
||||||
<entry key="app/src/main/res/layout/item_home_year_placeholder.xml" value="0.3229166666666667" />
|
<entry key="app/src/main/res/layout/item_home_year_placeholder.xml" value="0.3229166666666667" />
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class ArtistRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<List<Artist>> getStarredArtists() {
|
public MutableLiveData<List<Artist>> getStarredArtists() {
|
||||||
MutableLiveData<List<Artist>> starredArtists = new MutableLiveData<>(new ArrayList<>());
|
MutableLiveData<List<Artist>> starredArtists = new MutableLiveData<>();
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getAlbumSongListClient()
|
.getAlbumSongListClient()
|
||||||
|
|
@ -54,7 +54,7 @@ public class ArtistRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<List<Artist>> getArtists(boolean random, int size) {
|
public MutableLiveData<List<Artist>> getArtists(boolean random, int size) {
|
||||||
MutableLiveData<List<Artist>> listLiveArtists = new MutableLiveData<>(new ArrayList<>());
|
MutableLiveData<List<Artist>> listLiveArtists = new MutableLiveData<>();
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getBrowsingClient()
|
.getBrowsingClient()
|
||||||
|
|
@ -249,7 +249,7 @@ public class ArtistRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<ArrayList<Song>> getArtistRandomSong(FragmentActivity fragmentActivity, Artist artist, int count) {
|
public MutableLiveData<ArrayList<Song>> getArtistRandomSong(FragmentActivity fragmentActivity, Artist artist, int count) {
|
||||||
MutableLiveData<ArrayList<Song>> randomSongs = new MutableLiveData<>(new ArrayList());
|
MutableLiveData<ArrayList<Song>> randomSongs = new MutableLiveData<>();
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getBrowsingClient()
|
.getBrowsingClient()
|
||||||
|
|
@ -266,6 +266,7 @@ public class ArtistRepository {
|
||||||
for (int index = 0; index < albums.size(); index++) {
|
for (int index = 0; index < albums.size(); index++) {
|
||||||
albumRepository.getAlbumTracks(albums.get(index).getId()).observe(fragmentActivity, songs -> {
|
albumRepository.getAlbumTracks(albums.get(index).getId()).observe(fragmentActivity, songs -> {
|
||||||
ArrayList<Song> liveSongs = randomSongs.getValue();
|
ArrayList<Song> liveSongs = randomSongs.getValue();
|
||||||
|
if(liveSongs == null) liveSongs = new ArrayList<>();
|
||||||
Collections.shuffle(liveSongs);
|
Collections.shuffle(liveSongs);
|
||||||
liveSongs.addAll(songs);
|
liveSongs.addAll(songs);
|
||||||
randomSongs.setValue(liveSongs);
|
randomSongs.setValue(liveSongs);
|
||||||
|
|
@ -309,6 +310,7 @@ public class ArtistRepository {
|
||||||
|
|
||||||
private void addToMutableLiveData(MutableLiveData<List<Artist>> liveData, Artist artist) {
|
private void addToMutableLiveData(MutableLiveData<List<Artist>> liveData, Artist artist) {
|
||||||
List<Artist> liveArtists = liveData.getValue();
|
List<Artist> liveArtists = liveData.getValue();
|
||||||
|
if(liveArtists == null) liveArtists = new ArrayList<>();
|
||||||
liveArtists.add(artist);
|
liveArtists.add(artist);
|
||||||
liveData.setValue(liveArtists);
|
liveData.setValue(liveArtists);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ public class DownloadRepository {
|
||||||
private static final String TAG = "QueueRepository";
|
private static final String TAG = "QueueRepository";
|
||||||
|
|
||||||
private DownloadDao downloadDao;
|
private DownloadDao downloadDao;
|
||||||
private MutableLiveData<List<Download>> listLiveDownload = new MutableLiveData<>(new ArrayList<>());
|
|
||||||
|
|
||||||
public DownloadRepository(Application application) {
|
public DownloadRepository(Application application) {
|
||||||
AppDatabase database = AppDatabase.getInstance(application);
|
AppDatabase database = AppDatabase.getInstance(application);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public class PlaylistRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<List<Playlist>> getPlaylists(boolean random, int size) {
|
public MutableLiveData<List<Playlist>> getPlaylists(boolean random, int size) {
|
||||||
MutableLiveData<List<Playlist>> listLivePlaylists = new MutableLiveData<>(new ArrayList<>());
|
MutableLiveData<List<Playlist>> listLivePlaylists = new MutableLiveData<>();
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getPlaylistClient()
|
.getPlaylistClient()
|
||||||
|
|
@ -56,7 +56,7 @@ public class PlaylistRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<List<Song>> getPlaylistSongs(String id) {
|
public MutableLiveData<List<Song>> getPlaylistSongs(String id) {
|
||||||
MutableLiveData<List<Song>> listLivePlaylistSongs = new MutableLiveData<>(new ArrayList<>());
|
MutableLiveData<List<Song>> listLivePlaylistSongs = new MutableLiveData<>();
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getPlaylistClient()
|
.getPlaylistClient()
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public class SearchingRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<List<String>> getSuggestions(String query) {
|
public MutableLiveData<List<String>> getSuggestions(String query) {
|
||||||
MutableLiveData<List<String>> suggestions = new MutableLiveData<>(new ArrayList());
|
MutableLiveData<List<String>> suggestions = new MutableLiveData<>();
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getSearchingClient()
|
.getSearchingClient()
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ public class SongRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<List<Song>> getRandomSample(int number, Integer fromYear, Integer toYear) {
|
public MutableLiveData<List<Song>> getRandomSample(int number, Integer fromYear, Integer toYear) {
|
||||||
MutableLiveData<List<Song>> randomSongsSample = new MutableLiveData<>(new ArrayList<>());
|
MutableLiveData<List<Song>> randomSongsSample = new MutableLiveData<>();
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getAlbumSongListClient()
|
.getAlbumSongListClient()
|
||||||
|
|
@ -180,7 +180,7 @@ public class SongRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<List<Song>> getSongsByGenre(String id) {
|
public MutableLiveData<List<Song>> getSongsByGenre(String id) {
|
||||||
MutableLiveData<List<Song>> songsByGenre = new MutableLiveData<>(new ArrayList<>());
|
MutableLiveData<List<Song>> songsByGenre = new MutableLiveData<>();
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getAlbumSongListClient()
|
.getAlbumSongListClient()
|
||||||
|
|
@ -192,6 +192,7 @@ public class SongRepository {
|
||||||
List<Song> newSongs = new ArrayList<>(MappingUtil.mapSong(response.body().getSongsByGenre().getSongs()));
|
List<Song> newSongs = new ArrayList<>(MappingUtil.mapSong(response.body().getSongsByGenre().getSongs()));
|
||||||
List<Song> songs = songsByGenre.getValue();
|
List<Song> songs = songsByGenre.getValue();
|
||||||
|
|
||||||
|
if(songs == null) songs = new ArrayList<>();
|
||||||
songs.addAll(newSongs);
|
songs.addAll(newSongs);
|
||||||
Collections.shuffle(songs);
|
Collections.shuffle(songs);
|
||||||
|
|
||||||
|
|
@ -212,10 +213,9 @@ public class SongRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<List<Song>> getSongsByGenres(ArrayList<String> genresId) {
|
public MutableLiveData<List<Song>> getSongsByGenres(ArrayList<String> genresId) {
|
||||||
MutableLiveData<List<Song>> songsByGenre = new MutableLiveData<>(new ArrayList<>());
|
MutableLiveData<List<Song>> songsByGenre = new MutableLiveData<>();
|
||||||
|
|
||||||
for (String id : genresId)
|
for (String id : genresId)
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getAlbumSongListClient()
|
.getAlbumSongListClient()
|
||||||
.getSongsByGenre(id, 500, 0)
|
.getSongsByGenre(id, 500, 0)
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ public class AlbumCatalogueViewModel extends AndroidViewModel {
|
||||||
@Override
|
@Override
|
||||||
public void onLoadMedia(List<?> media) {
|
public void onLoadMedia(List<?> media) {
|
||||||
List<Album> liveAlbum = albumList.getValue();
|
List<Album> liveAlbum = albumList.getValue();
|
||||||
|
if(liveAlbum == null) liveAlbum = new ArrayList<>();
|
||||||
liveAlbum.addAll(MappingUtil.mapAlbum((List<AlbumID3>) media));
|
liveAlbum.addAll(MappingUtil.mapAlbum((List<AlbumID3>) media));
|
||||||
albumList.setValue(liveAlbum);
|
albumList.setValue(liveAlbum);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue