mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
feat: added sorting by newest album added
This commit is contained in:
parent
302458e76b
commit
2712b73dac
7 changed files with 47 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ import retrofit2.Callback;
|
|||
|
||||
public class AlbumCatalogueViewModel extends AndroidViewModel {
|
||||
private final MutableLiveData<List<AlbumID3>> albumList = new MutableLiveData<>(new ArrayList<>());
|
||||
private final MutableLiveData<Boolean> loading = new MutableLiveData<>(true);
|
||||
|
||||
private int page = 0;
|
||||
private Status status = Status.STOPPED;
|
||||
|
|
@ -32,6 +33,10 @@ public class AlbumCatalogueViewModel extends AndroidViewModel {
|
|||
return albumList;
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getLoadingStatus() {
|
||||
return loading;
|
||||
}
|
||||
|
||||
public void loadAlbums() {
|
||||
page = 0;
|
||||
status = Status.RUNNING;
|
||||
|
|
@ -52,6 +57,7 @@ public class AlbumCatalogueViewModel extends AndroidViewModel {
|
|||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
if (status == Status.STOPPED) {
|
||||
loading.setValue(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -62,8 +68,10 @@ public class AlbumCatalogueViewModel extends AndroidViewModel {
|
|||
|
||||
if (media.size() == size) {
|
||||
loadAlbums(size);
|
||||
loading.setValue(true);
|
||||
} else {
|
||||
status = Status.STOPPED;
|
||||
loading.setValue(false);
|
||||
}
|
||||
}
|
||||
}, size, size * page++);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue