mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 02:13:33 +00:00
feat: add sorting and search functionality for song list
This commit is contained in:
parent
780f1c3a2e
commit
9e6926fc97
8 changed files with 198 additions and 9 deletions
|
|
@ -36,6 +36,8 @@ public class SongListPageViewModel extends AndroidViewModel {
|
|||
public ArrayList<String> filterNames = new ArrayList<>();
|
||||
|
||||
public int year = 0;
|
||||
public int maxNumberByYear = 500;
|
||||
public int maxNumberByGenre = 100;
|
||||
|
||||
public SongListPageViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
|
@ -58,7 +60,7 @@ public class SongListPageViewModel extends AndroidViewModel {
|
|||
songList = songRepository.getSongsByGenres(filters);
|
||||
break;
|
||||
case Constants.MEDIA_BY_YEAR:
|
||||
songList = songRepository.getRandomSample(500, year, year + 10);
|
||||
songList = songRepository.getRandomSample(maxNumberByYear, year, year + 10);
|
||||
break;
|
||||
case Constants.MEDIA_STARRED:
|
||||
songList = songRepository.getStarredSongs(false, -1);
|
||||
|
|
@ -73,9 +75,9 @@ public class SongListPageViewModel extends AndroidViewModel {
|
|||
case Constants.MEDIA_BY_GENRE:
|
||||
int songCount = songList.getValue() != null ? songList.getValue().size() : 0;
|
||||
|
||||
if (songCount > 0 && songCount % 100 != 0) return;
|
||||
if (songCount > 0 && songCount % maxNumberByGenre != 0) return;
|
||||
|
||||
int page = songCount / 100;
|
||||
int page = songCount / maxNumberByGenre;
|
||||
songRepository.getSongsByGenre(genre.getGenre(), page).observe(owner, children -> {
|
||||
if (children != null && !children.isEmpty()) {
|
||||
List<Child> currentMedia = songList.getValue();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue