use of com.simplecity.amp_library.model.AlbumArtist in project Shuttle by timusus.
the class AlbumArtistFragment method refreshAdapterItems.
void refreshAdapterItems(boolean force) {
PermissionUtils.RequestStoragePermissions(() -> {
if (getActivity() != null && isAdded()) {
int artistDisplayType = SettingsManager.getInstance().getArtistDisplayType();
boolean ascending = SortManager.getInstance().getArtistsAscending();
disposable = DataManager.getInstance().getAlbumArtistsRelay().skipWhile(albumArtists -> !force && adapter.items.size() == albumArtists.size()).debounce(150, TimeUnit.MILLISECONDS).flatMapSingle(albumArtists -> {
// Sort
SortManager.getInstance().sortAlbumArtists(albumArtists);
// Reverse if required
if (!ascending) {
Collections.reverse(albumArtists);
}
return Observable.fromIterable(albumArtists).map(albumArtist -> {
// Look for an existing AlbumArtistView wrapping the song, we'll reuse it if it exists.
AlbumArtistView albumArtistView = (AlbumArtistView) Stream.of(adapter.items).filter(viewModel -> viewModel instanceof AlbumArtistView && (((AlbumArtistView) viewModel).albumArtist.equals(albumArtist))).findFirst().orElse(null);
if (albumArtistView == null) {
albumArtistView = new AlbumArtistView(albumArtist, artistDisplayType, requestManager);
albumArtistView.setClickListener(this);
}
return (ViewModel) albumArtistView;
}).toList();
}).observeOn(AndroidSchedulers.mainThread()).subscribe(items -> {
if (items.isEmpty()) {
adapter.setItems(Collections.singletonList(new EmptyView(R.string.empty_artists)));
} else {
adapter.setItems(items);
}
// Move the RV back to the top if we've had a sort order change.
if (sortOrderChanged) {
recyclerView.scrollToPosition(0);
}
sortOrderChanged = false;
});
}
});
}
use of com.simplecity.amp_library.model.AlbumArtist in project Shuttle by timusus.
the class PlayerFragment method goToArtist.
@SuppressLint("CheckResult")
private void goToArtist() {
AlbumArtist currentAlbumArtist = MusicUtils.getAlbumArtist();
// MusicUtils.getAlbumArtist() is only populate with the album the current Song belongs to.
// Let's find the matching AlbumArtist in the DataManager.albumArtistRelay
DataManager.getInstance().getAlbumArtistsRelay().first(Collections.emptyList()).flatMapObservable(Observable::fromIterable).filter(albumArtist -> currentAlbumArtist != null && albumArtist.name.equals(currentAlbumArtist.name) && albumArtist.albums.containsAll(currentAlbumArtist.albums)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(albumArtist -> navigationEventRelay.sendEvent(new NavigationEventRelay.NavigationEvent(NavigationEventRelay.NavigationEvent.Type.GO_TO_ARTIST, albumArtist, true)));
}
Aggregations