mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-01 15:03:37 +00:00
fix: null checking
This commit is contained in:
@@ -58,11 +58,13 @@ public class AlbumRepository {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getStarred2() != null) {
|
||||
List<AlbumID3> albums = response.body().getSubsonicResponse().getStarred2().getAlbums();
|
||||
|
||||
if (random) {
|
||||
Collections.shuffle(albums);
|
||||
starredAlbums.setValue(albums.subList(0, Math.min(size, albums.size())));
|
||||
} else {
|
||||
starredAlbums.setValue(albums);
|
||||
if (albums != null) {
|
||||
if (random) {
|
||||
Collections.shuffle(albums);
|
||||
starredAlbums.setValue(albums.subList(0, Math.min(size, albums.size())));
|
||||
} else {
|
||||
starredAlbums.setValue(albums);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,13 @@ public class ArtistRepository {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().getSubsonicResponse().getStarred2() != null) {
|
||||
List<ArtistID3> artists = response.body().getSubsonicResponse().getStarred2().getArtists();
|
||||
|
||||
if (!random) {
|
||||
getArtistInfo(artists, starredArtists);
|
||||
} else {
|
||||
Collections.shuffle(artists);
|
||||
getArtistInfo(artists.subList(0, Math.min(size, artists.size())), starredArtists);
|
||||
if (artists != null) {
|
||||
if (!random) {
|
||||
getArtistInfo(artists, starredArtists);
|
||||
} else {
|
||||
Collections.shuffle(artists);
|
||||
getArtistInfo(artists.subList(0, Math.min(size, artists.size())), starredArtists);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.subsonic.models.AlbumID3;
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistID3;
|
||||
import com.cappielloantonio.play.subsonic.models.Child;
|
||||
import com.cappielloantonio.play.subsonic.models.PodcastEpisode;
|
||||
import com.cappielloantonio.play.util.Preferences;
|
||||
|
||||
import java.util.Calendar;
|
||||
@@ -81,8 +80,10 @@ public class HomeViewModel extends AndroidViewModel {
|
||||
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
|
||||
albumRepository.getAlbums("byYear", 500, currentYear, currentYear).observe(owner, albums -> {
|
||||
albums.sort(Comparator.comparing(AlbumID3::getCreated).reversed());
|
||||
newReleasedAlbum.postValue(albums.subList(0, Math.min(20, albums.size())));
|
||||
if (albums != null) {
|
||||
albums.sort(Comparator.comparing(AlbumID3::getCreated).reversed());
|
||||
newReleasedAlbum.postValue(albums.subList(0, Math.min(20, albums.size())));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user