mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Add "New releases" view in library page
This commit is contained in:
parent
46dc173958
commit
9ae9873326
9 changed files with 116 additions and 14 deletions
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
|
|
@ -5,6 +5,7 @@
|
||||||
<map>
|
<map>
|
||||||
<entry key="../../.gradle/caches/transforms-3/cfd4e4d299e24db95f3608b5f72af22b/transformed/jetified-exoplayer-ui-2.12.2/res/drawable-anydpi-v21/exo_ic_play_circle_filled.xml" value="0.28055555555555556" />
|
<entry key="../../.gradle/caches/transforms-3/cfd4e4d299e24db95f3608b5f72af22b/transformed/jetified-exoplayer-ui-2.12.2/res/drawable-anydpi-v21/exo_ic_play_circle_filled.xml" value="0.28055555555555556" />
|
||||||
<entry key="app/src/main/res/drawable-v24/ic_add.xml" value="0.27685185185185185" />
|
<entry key="app/src/main/res/drawable-v24/ic_add.xml" value="0.27685185185185185" />
|
||||||
|
<entry key="app/src/main/res/drawable-v24/ic_cast.xml" value="0.28055555555555556" />
|
||||||
<entry key="app/src/main/res/drawable-v24/ic_download.xml" value="0.27685185185185185" />
|
<entry key="app/src/main/res/drawable-v24/ic_download.xml" value="0.27685185185185185" />
|
||||||
<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_play_for_work.xml" value="0.28055555555555556" />
|
<entry key="app/src/main/res/drawable-v24/ic_play_for_work.xml" value="0.28055555555555556" />
|
||||||
|
|
@ -50,7 +51,7 @@
|
||||||
<entry key="app/src/main/res/layout/fragment_artist_page.xml" value="0.1" />
|
<entry key="app/src/main/res/layout/fragment_artist_page.xml" value="0.1" />
|
||||||
<entry key="app/src/main/res/layout/fragment_download.xml" value="0.283363802559415" />
|
<entry key="app/src/main/res/layout/fragment_download.xml" value="0.283363802559415" />
|
||||||
<entry key="app/src/main/res/layout/fragment_home.xml" value="0.283363802559415" />
|
<entry key="app/src/main/res/layout/fragment_home.xml" value="0.283363802559415" />
|
||||||
<entry key="app/src/main/res/layout/fragment_library.xml" value="0.3229166666666667" />
|
<entry key="app/src/main/res/layout/fragment_library.xml" value="0.1" />
|
||||||
<entry key="app/src/main/res/layout/fragment_login.xml" value="0.3166496424923391" />
|
<entry key="app/src/main/res/layout/fragment_login.xml" value="0.3166496424923391" />
|
||||||
<entry key="app/src/main/res/layout/fragment_player_bottom_sheet.xml" value="0.3166496424923391" />
|
<entry key="app/src/main/res/layout/fragment_player_bottom_sheet.xml" value="0.3166496424923391" />
|
||||||
<entry key="app/src/main/res/layout/fragment_playlist_catalogue.xml" value="0.3229166666666667" />
|
<entry key="app/src/main/res/layout/fragment_playlist_catalogue.xml" value="0.3229166666666667" />
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,8 @@ public class AlbumHorizontalAdapter extends RecyclerView.Adapter<AlbumHorizontal
|
||||||
Navigation.findNavController(view).navigate(R.id.action_albumListPageFragment_to_albumPageFragment, bundle);
|
Navigation.findNavController(view).navigate(R.id.action_albumListPageFragment_to_albumPageFragment, bundle);
|
||||||
} else if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.downloadFragment) {
|
} else if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.downloadFragment) {
|
||||||
Navigation.findNavController(view).navigate(R.id.action_downloadFragment_to_albumPageFragment, bundle);
|
Navigation.findNavController(view).navigate(R.id.action_downloadFragment_to_albumPageFragment, bundle);
|
||||||
|
} else if (Objects.requireNonNull(Navigation.findNavController(view).getCurrentDestination()).getId() == R.id.libraryFragment) {
|
||||||
|
Navigation.findNavController(view).navigate(R.id.action_libraryFragment_to_albumPageFragment, bundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.cappielloantonio.play.subsonic.models.AlbumInfo;
|
||||||
import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3;
|
import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3;
|
||||||
import com.cappielloantonio.play.util.MappingUtil;
|
import com.cappielloantonio.play.util.MappingUtil;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Album implements Parcelable {
|
public class Album implements Parcelable {
|
||||||
|
|
@ -32,6 +33,7 @@ public class Album implements Parcelable {
|
||||||
private boolean favorite;
|
private boolean favorite;
|
||||||
private List<Song> songs;
|
private List<Song> songs;
|
||||||
private String notes;
|
private String notes;
|
||||||
|
private Date created;
|
||||||
|
|
||||||
public Album(AlbumID3 albumID3) {
|
public Album(AlbumID3 albumID3) {
|
||||||
this.id = albumID3.getId();
|
this.id = albumID3.getId();
|
||||||
|
|
@ -41,6 +43,7 @@ public class Album implements Parcelable {
|
||||||
this.artistName = albumID3.getArtist();
|
this.artistName = albumID3.getArtist();
|
||||||
this.primary = albumID3.getCoverArtId();
|
this.primary = albumID3.getCoverArtId();
|
||||||
this.favorite = albumID3.getStarred() != null;
|
this.favorite = albumID3.getStarred() != null;
|
||||||
|
this.created = albumID3.getCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Album(AlbumWithSongsID3 albumWithSongsID3) {
|
public Album(AlbumWithSongsID3 albumWithSongsID3) {
|
||||||
|
|
@ -52,6 +55,7 @@ public class Album implements Parcelable {
|
||||||
this.primary = albumWithSongsID3.getCoverArtId();
|
this.primary = albumWithSongsID3.getCoverArtId();
|
||||||
this.favorite = albumWithSongsID3.getStarred() != null;
|
this.favorite = albumWithSongsID3.getStarred() != null;
|
||||||
this.songs = MappingUtil.mapSong(albumWithSongsID3.getSongs());
|
this.songs = MappingUtil.mapSong(albumWithSongsID3.getSongs());
|
||||||
|
this.created = albumWithSongsID3.getCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Album(Download download) {
|
public Album(Download download) {
|
||||||
|
|
@ -146,6 +150,14 @@ public class Album implements Parcelable {
|
||||||
this.notes = notes;
|
this.notes = notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getCreated() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreated(Date created) {
|
||||||
|
this.created = created;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,12 @@ public class AlbumRepository {
|
||||||
this.application = application;
|
this.application = application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<List<Album>> getAlbums(String type, int size) {
|
public MutableLiveData<List<Album>> getAlbums(String type, int size, Integer fromYear, Integer toYear) {
|
||||||
MutableLiveData<List<Album>> listLiveAlbums = new MutableLiveData<>();
|
MutableLiveData<List<Album>> listLiveAlbums = new MutableLiveData<>();
|
||||||
|
|
||||||
App.getSubsonicClientInstance(application, false)
|
App.getSubsonicClientInstance(application, false)
|
||||||
.getAlbumSongListClient()
|
.getAlbumSongListClient()
|
||||||
.getAlbumList2(type, size, 0, null, null)
|
.getAlbumList2(type, size, 0, fromYear, toYear)
|
||||||
.enqueue(new Callback<SubsonicResponse>() {
|
.enqueue(new Callback<SubsonicResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
public void onResponse(@NonNull Call<SubsonicResponse> call, @NonNull Response<SubsonicResponse> response) {
|
||||||
|
|
|
||||||
|
|
@ -15,17 +15,22 @@ import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.PagerSnapHelper;
|
||||||
|
import androidx.recyclerview.widget.SnapHelper;
|
||||||
import androidx.viewpager2.widget.ViewPager2;
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
import com.cappielloantonio.play.R;
|
import com.cappielloantonio.play.R;
|
||||||
import com.cappielloantonio.play.adapter.AlbumAdapter;
|
import com.cappielloantonio.play.adapter.AlbumAdapter;
|
||||||
|
import com.cappielloantonio.play.adapter.AlbumHorizontalAdapter;
|
||||||
import com.cappielloantonio.play.adapter.ArtistAdapter;
|
import com.cappielloantonio.play.adapter.ArtistAdapter;
|
||||||
import com.cappielloantonio.play.adapter.GenreAdapter;
|
import com.cappielloantonio.play.adapter.GenreAdapter;
|
||||||
import com.cappielloantonio.play.adapter.PlaylistAdapter;
|
import com.cappielloantonio.play.adapter.PlaylistAdapter;
|
||||||
import com.cappielloantonio.play.databinding.FragmentLibraryBinding;
|
import com.cappielloantonio.play.databinding.FragmentLibraryBinding;
|
||||||
import com.cappielloantonio.play.helper.recyclerview.CustomLinearSnapHelper;
|
import com.cappielloantonio.play.helper.recyclerview.CustomLinearSnapHelper;
|
||||||
|
import com.cappielloantonio.play.helper.recyclerview.DotsIndicatorDecoration;
|
||||||
import com.cappielloantonio.play.model.Song;
|
import com.cappielloantonio.play.model.Song;
|
||||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||||
|
import com.cappielloantonio.play.util.UIUtil;
|
||||||
import com.cappielloantonio.play.viewmodel.LibraryViewModel;
|
import com.cappielloantonio.play.viewmodel.LibraryViewModel;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -37,6 +42,7 @@ public class LibraryFragment extends Fragment {
|
||||||
private MainActivity activity;
|
private MainActivity activity;
|
||||||
private LibraryViewModel libraryViewModel;
|
private LibraryViewModel libraryViewModel;
|
||||||
|
|
||||||
|
private AlbumHorizontalAdapter newRelesesAlbumAdapter;
|
||||||
private AlbumAdapter albumAdapter;
|
private AlbumAdapter albumAdapter;
|
||||||
private ArtistAdapter artistAdapter;
|
private ArtistAdapter artistAdapter;
|
||||||
private GenreAdapter genreAdapter;
|
private GenreAdapter genreAdapter;
|
||||||
|
|
@ -73,6 +79,7 @@ public class LibraryFragment extends Fragment {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
initAppBar();
|
initAppBar();
|
||||||
|
initNewReleasesView();
|
||||||
initAlbumView();
|
initAlbumView();
|
||||||
initArtistView();
|
initArtistView();
|
||||||
initGenreView();
|
initGenreView();
|
||||||
|
|
@ -136,6 +143,37 @@ public class LibraryFragment extends Fragment {
|
||||||
Objects.requireNonNull(bind.toolbar.getOverflowIcon()).setTint(requireContext().getResources().getColor(R.color.titleTextColor, null));
|
Objects.requireNonNull(bind.toolbar.getOverflowIcon()).setTint(requireContext().getResources().getColor(R.color.titleTextColor, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initNewReleasesView() {
|
||||||
|
bind.newReleasesRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
|
newRelesesAlbumAdapter = new AlbumHorizontalAdapter(requireContext());
|
||||||
|
bind.newReleasesRecyclerView.setAdapter(newRelesesAlbumAdapter);
|
||||||
|
libraryViewModel.getRecentlyReleasedAlbums(requireActivity()).observe(requireActivity(), albums -> {
|
||||||
|
if (albums == null) {
|
||||||
|
if (bind != null) bind.libraryNewReleasesPlaceholder.placeholder.setVisibility(View.VISIBLE);
|
||||||
|
if (bind != null) bind.libraryNewReleasesSector.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
if (bind != null) bind.libraryNewReleasesPlaceholder.placeholder.setVisibility(View.GONE);
|
||||||
|
if (bind != null) bind.libraryNewReleasesSector.setVisibility(!albums.isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
|
if (bind != null) bind.newReleasesRecyclerView.setLayoutManager(new GridLayoutManager(requireContext(), UIUtil.getSpanCount(albums.size(), 5), GridLayoutManager.HORIZONTAL, false));
|
||||||
|
|
||||||
|
newRelesesAlbumAdapter.setItems(albums);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
SnapHelper starredAlbumSnapHelper = new PagerSnapHelper();
|
||||||
|
starredAlbumSnapHelper.attachToRecyclerView(bind.newReleasesRecyclerView);
|
||||||
|
|
||||||
|
bind.newReleasesRecyclerView.addItemDecoration(
|
||||||
|
new DotsIndicatorDecoration(
|
||||||
|
getResources().getDimensionPixelSize(R.dimen.radius),
|
||||||
|
getResources().getDimensionPixelSize(R.dimen.radius) * 4,
|
||||||
|
getResources().getDimensionPixelSize(R.dimen.dots_height),
|
||||||
|
requireContext().getResources().getColor(R.color.titleTextColor, null),
|
||||||
|
requireContext().getResources().getColor(R.color.titleTextColor, null))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private void initAlbumView() {
|
private void initAlbumView() {
|
||||||
bind.albumRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
bind.albumRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||||
bind.albumRecyclerView.setHasFixedSize(true);
|
bind.albumRecyclerView.setHasFixedSize(true);
|
||||||
|
|
|
||||||
|
|
@ -39,17 +39,17 @@ public class AlbumListPageViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
switch (title) {
|
switch (title) {
|
||||||
case Album.RECENTLY_PLAYED:
|
case Album.RECENTLY_PLAYED:
|
||||||
albumRepository.getAlbums("recent", 500).observe(activity, albums -> {
|
albumRepository.getAlbums("recent", 500, null, null).observe(activity, albums -> {
|
||||||
albumList.setValue(albums);
|
albumList.setValue(albums);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case Album.MOST_PLAYED:
|
case Album.MOST_PLAYED:
|
||||||
albumRepository.getAlbums("frequent", 500).observe(activity, albums -> {
|
albumRepository.getAlbums("frequent", 500, null, null).observe(activity, albums -> {
|
||||||
albumList.setValue(albums);
|
albumList.setValue(albums);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case Album.RECENTLY_ADDED:
|
case Album.RECENTLY_ADDED:
|
||||||
albumRepository.getAlbums("newest", 500).observe(activity, albums -> {
|
albumRepository.getAlbums("newest", 500, null, null).observe(activity, albums -> {
|
||||||
albumList.setValue(albums);
|
albumList.setValue(albums);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -77,17 +77,17 @@ public class HomeViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Album>> getMostPlayedAlbums(LifecycleOwner owner) {
|
public LiveData<List<Album>> getMostPlayedAlbums(LifecycleOwner owner) {
|
||||||
albumRepository.getAlbums("frequent", 20).observe(owner, mostPlayedAlbumSample::postValue);
|
albumRepository.getAlbums("frequent", 20, null, null).observe(owner, mostPlayedAlbumSample::postValue);
|
||||||
return mostPlayedAlbumSample;
|
return mostPlayedAlbumSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Album>> getMostRecentlyAddedAlbums(LifecycleOwner owner) {
|
public LiveData<List<Album>> getMostRecentlyAddedAlbums(LifecycleOwner owner) {
|
||||||
albumRepository.getAlbums("newest", 20).observe(owner, recentlyAddedAlbumSample::postValue);
|
albumRepository.getAlbums("newest", 20, null, null).observe(owner, recentlyAddedAlbumSample::postValue);
|
||||||
return recentlyAddedAlbumSample;
|
return recentlyAddedAlbumSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Album>> getRecentlyPlayedAlbumList(LifecycleOwner owner) {
|
public LiveData<List<Album>> getRecentlyPlayedAlbumList(LifecycleOwner owner) {
|
||||||
albumRepository.getAlbums("recent", 20).observe(owner, recentlyPlayedAlbumSample::postValue);
|
albumRepository.getAlbums("recent", 20, null, null).observe(owner, recentlyPlayedAlbumSample::postValue);
|
||||||
return recentlyPlayedAlbumSample;
|
return recentlyPlayedAlbumSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,14 +112,14 @@ public class HomeViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshMostPlayedAlbums(LifecycleOwner owner) {
|
public void refreshMostPlayedAlbums(LifecycleOwner owner) {
|
||||||
albumRepository.getAlbums("frequent", 20).observe(owner, mostPlayedAlbumSample::postValue);
|
albumRepository.getAlbums("frequent", 20, null, null).observe(owner, mostPlayedAlbumSample::postValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshMostRecentlyAddedAlbums(LifecycleOwner owner) {
|
public void refreshMostRecentlyAddedAlbums(LifecycleOwner owner) {
|
||||||
albumRepository.getAlbums("newest", 20).observe(owner, recentlyAddedAlbumSample::postValue);
|
albumRepository.getAlbums("newest", 20, null, null).observe(owner, recentlyAddedAlbumSample::postValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshRecentlyPlayedAlbumList(LifecycleOwner owner) {
|
public void refreshRecentlyPlayedAlbumList(LifecycleOwner owner) {
|
||||||
albumRepository.getAlbums("recent", 20).observe(owner, recentlyPlayedAlbumSample::postValue);
|
albumRepository.getAlbums("recent", 20, null, null).observe(owner, recentlyPlayedAlbumSample::postValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,14 @@ import com.cappielloantonio.play.repository.ArtistRepository;
|
||||||
import com.cappielloantonio.play.repository.GenreRepository;
|
import com.cappielloantonio.play.repository.GenreRepository;
|
||||||
import com.cappielloantonio.play.repository.PlaylistRepository;
|
import com.cappielloantonio.play.repository.PlaylistRepository;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LibraryViewModel extends AndroidViewModel {
|
public class LibraryViewModel extends AndroidViewModel {
|
||||||
|
private static final String TAG = "LibraryViewModel";
|
||||||
|
|
||||||
private final AlbumRepository albumRepository;
|
private final AlbumRepository albumRepository;
|
||||||
private final ArtistRepository artistRepository;
|
private final ArtistRepository artistRepository;
|
||||||
private final GenreRepository genreRepository;
|
private final GenreRepository genreRepository;
|
||||||
|
|
@ -27,6 +32,7 @@ public class LibraryViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
private final MutableLiveData<List<Playlist>> playlistSample = new MutableLiveData<>(null);
|
private final MutableLiveData<List<Playlist>> playlistSample = new MutableLiveData<>(null);
|
||||||
private final MutableLiveData<List<Album>> sampleAlbum = new MutableLiveData<>(null);
|
private final MutableLiveData<List<Album>> sampleAlbum = new MutableLiveData<>(null);
|
||||||
|
private final MutableLiveData<List<Album>> newReleasedAlbum = new MutableLiveData<>(null);
|
||||||
private final MutableLiveData<List<Artist>> sampleArtist = new MutableLiveData<>(null);
|
private final MutableLiveData<List<Artist>> sampleArtist = new MutableLiveData<>(null);
|
||||||
private final MutableLiveData<List<Genre>> sampleGenres = new MutableLiveData<>(null);
|
private final MutableLiveData<List<Genre>> sampleGenres = new MutableLiveData<>(null);
|
||||||
|
|
||||||
|
|
@ -40,12 +46,23 @@ public class LibraryViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
// Inizializzate all'interno del costruttore, in modo da rimanere immutabili per tutto il
|
// Inizializzate all'interno del costruttore, in modo da rimanere immutabili per tutto il
|
||||||
// ciclo di vita dell'applicazione
|
// ciclo di vita dell'applicazione
|
||||||
albumRepository.getAlbums("random", 20).observeForever(sampleAlbum::postValue);
|
albumRepository.getAlbums("random", 20, null, null).observeForever(sampleAlbum::postValue);
|
||||||
artistRepository.getArtists(true, 20).observeForever(sampleArtist::postValue);
|
artistRepository.getArtists(true, 20).observeForever(sampleArtist::postValue);
|
||||||
genreRepository.getGenres(true, 15).observeForever(sampleGenres::postValue);
|
genreRepository.getGenres(true, 15).observeForever(sampleGenres::postValue);
|
||||||
playlistRepository.getPlaylists(true, 10).observeForever(playlistSample::postValue);
|
playlistRepository.getPlaylists(true, 10).observeForever(playlistSample::postValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Album>> getRecentlyReleasedAlbums(LifecycleOwner owner) {
|
||||||
|
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||||
|
|
||||||
|
albumRepository.getAlbums("byYear", 500, currentYear, currentYear).observe(owner, albums -> {
|
||||||
|
albums.sort(Comparator.comparing(Album::getCreated).reversed());
|
||||||
|
newReleasedAlbum.postValue(albums.subList(0, Math.min(20, albums.size())));
|
||||||
|
});
|
||||||
|
|
||||||
|
return newReleasedAlbum;
|
||||||
|
}
|
||||||
|
|
||||||
public LiveData<List<Album>> getAlbumSample() {
|
public LiveData<List<Album>> getAlbumSample() {
|
||||||
return sampleAlbum;
|
return sampleAlbum;
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +80,7 @@ public class LibraryViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshAlbumSample(LifecycleOwner owner) {
|
public void refreshAlbumSample(LifecycleOwner owner) {
|
||||||
albumRepository.getAlbums("random", 20).observe(owner, sampleAlbum::postValue);
|
albumRepository.getAlbums("random", 20, null, null).observe(owner, sampleAlbum::postValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshArtistSample(LifecycleOwner owner) {
|
public void refreshArtistSample(LifecycleOwner owner) {
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,38 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="@dimen/global_padding_bottom">
|
android:paddingBottom="@dimen/global_padding_bottom">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/library_new_releases_sector"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
|
<!-- New releases -->
|
||||||
|
<TextView
|
||||||
|
style="@style/HeadlineTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp"
|
||||||
|
android:text="New releases" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/new_releases_recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="8dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/library_new_releases_placeholder"
|
||||||
|
layout="@layout/item_placeholder_horizontal"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/library_album_sector"
|
android:id="@+id/library_album_sector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue