mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
use getRandomSampleWithGenre() rather than getSongsByGenre()
This commit is contained in:
parent
8ce0a82506
commit
35784216bc
2 changed files with 29 additions and 2 deletions
|
|
@ -100,6 +100,33 @@ public class SongRepository {
|
||||||
return randomSongsSample;
|
return randomSongsSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<List<Child>> getRandomSampleWithGenre(int number, Integer fromYear, Integer toYear, String genre) {
|
||||||
|
MutableLiveData<List<Child>> randomSongsSample = new MutableLiveData<>();
|
||||||
|
|
||||||
|
App.getSubsonicClientInstance(false)
|
||||||
|
.getAlbumSongListClient()
|
||||||
|
.getRandomSongs2(number, fromYear, toYear, genre)
|
||||||
|
.enqueue(new Callback<ApiResponse>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<ApiResponse> call, @NonNull Response<ApiResponse> response) {
|
||||||
|
List<Child> songs = new ArrayList<>();
|
||||||
|
|
||||||
|
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getRandomSongs() != null && response.body().getSubsonicResponse().getRandomSongs().getSongs() != null) {
|
||||||
|
songs.addAll(response.body().getSubsonicResponse().getRandomSongs().getSongs());
|
||||||
|
}
|
||||||
|
|
||||||
|
randomSongsSample.setValue(songs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<ApiResponse> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return randomSongsSample;
|
||||||
|
}
|
||||||
|
|
||||||
public void scrobble(String id, boolean submission) {
|
public void scrobble(String id, boolean submission) {
|
||||||
App.getSubsonicClientInstance(false)
|
App.getSubsonicClientInstance(false)
|
||||||
.getMediaAnnotationClient()
|
.getMediaAnnotationClient()
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class SongListPageViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
public int year = 0;
|
public int year = 0;
|
||||||
public int maxNumberByYear = 500;
|
public int maxNumberByYear = 500;
|
||||||
public int maxNumberByGenre = 100;
|
public int maxNumberByGenre = 500;
|
||||||
|
|
||||||
public SongListPageViewModel(@NonNull Application application) {
|
public SongListPageViewModel(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
|
|
@ -51,7 +51,7 @@ public class SongListPageViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
switch (title) {
|
switch (title) {
|
||||||
case Constants.MEDIA_BY_GENRE:
|
case Constants.MEDIA_BY_GENRE:
|
||||||
songList = songRepository.getSongsByGenre(genre.getGenre(), 0);
|
songList = songRepository.getRandomSampleWithGenre(maxNumberByGenre, 0, 3000, genre.getGenre());
|
||||||
break;
|
break;
|
||||||
case Constants.MEDIA_BY_ARTIST:
|
case Constants.MEDIA_BY_ARTIST:
|
||||||
songList = artistRepository.getTopSongs(artist.getName(), 50);
|
songList = artistRepository.getTopSongs(artist.getName(), 50);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue