mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
feat: implemented customizable home, allowing users to toggle visibility of elements and change their order
This commit is contained in:
parent
309eca0764
commit
0e97eab744
12 changed files with 507 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
import com.cappielloantonio.tempo.interfaces.StarCallback;
|
||||
import com.cappielloantonio.tempo.model.Chronology;
|
||||
import com.cappielloantonio.tempo.model.Favorite;
|
||||
import com.cappielloantonio.tempo.model.HomeSector;
|
||||
import com.cappielloantonio.tempo.repository.AlbumRepository;
|
||||
import com.cappielloantonio.tempo.repository.ArtistRepository;
|
||||
import com.cappielloantonio.tempo.repository.ChronologyRepository;
|
||||
|
|
@ -22,6 +23,8 @@ import com.cappielloantonio.tempo.subsonic.models.ArtistID3;
|
|||
import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||
import com.cappielloantonio.tempo.subsonic.models.Share;
|
||||
import com.cappielloantonio.tempo.util.Preferences;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
|
@ -59,10 +62,13 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
private final MutableLiveData<List<Child>> artistBestOf = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Share>> shares = new MutableLiveData<>(null);
|
||||
|
||||
private List<HomeSector> sectors;
|
||||
|
||||
public HomeViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
setHomeSectorList();
|
||||
|
||||
songRepository = new SongRepository();
|
||||
albumRepository = new AlbumRepository();
|
||||
artistRepository = new ArtistRepository();
|
||||
|
|
@ -266,6 +272,26 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
sharingRepository.getShares().observe(owner, this.shares::postValue);
|
||||
}
|
||||
|
||||
private void setHomeSectorList() {
|
||||
if (Preferences.getHomeSectorList() != null && !Preferences.getHomeSectorList().equals("null")) {
|
||||
sectors = new Gson().fromJson(
|
||||
Preferences.getHomeSectorList(),
|
||||
new TypeToken<List<HomeSector>>() {
|
||||
}.getType()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public List<HomeSector> getHomeSectorList() {
|
||||
return sectors;
|
||||
}
|
||||
|
||||
public boolean checkHomeSectorVisibility(String sectorId) {
|
||||
return sectors != null && sectors.stream().filter(sector -> sector.getId().equals(sectorId))
|
||||
.findAny()
|
||||
.orElse(null) != null;
|
||||
}
|
||||
|
||||
public void setOfflineFavorite() {
|
||||
ArrayList<Favorite> favorites = getFavorites();
|
||||
ArrayList<Favorite> favoritesToSave = getFavoritesToSave(favorites);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue