use of com.simplecity.amp_library.model.AlbumArtist in project Shuttle by timusus.
the class MainController method onResume.
@Override
public void onResume() {
super.onResume();
if (delayHandler != null) {
delayHandler.removeCallbacksAndMessages(null);
}
delayHandler = new Handler();
disposables.add(navigationEventRelay.getEvents().observeOn(AndroidSchedulers.mainThread()).filter(NavigationEventRelay.NavigationEvent::isActionable).subscribe(navigationEvent -> {
switch(navigationEvent.type) {
case NavigationEventRelay.NavigationEvent.Type.LIBRARY_SELECTED:
popToRootViewController();
break;
case NavigationEventRelay.NavigationEvent.Type.FOLDERS_SELECTED:
delayHandler.postDelayed(() -> pushViewController(FolderFragment.newInstance(getString(R.string.folders_title), false), "FolderFragment"), 250);
break;
case NavigationEventRelay.NavigationEvent.Type.SLEEP_TIMER_SELECTED:
UnsafeAction showToast = () -> Toast.makeText(getContext(), R.string.sleep_timer_started, Toast.LENGTH_SHORT).show();
SleepTimer.getInstance().getDialog(getContext(), () -> SleepTimer.getInstance().showMinutesDialog(getContext(), showToast), showToast).show();
break;
case NavigationEventRelay.NavigationEvent.Type.EQUALIZER_SELECTED:
delayHandler.postDelayed(() -> multiSheetEventRelay.sendEvent(new MultiSheetEventRelay.MultiSheetEvent(MultiSheetEventRelay.MultiSheetEvent.Action.HIDE, MultiSheetView.Sheet.FIRST)), 100);
delayHandler.postDelayed(() -> pushViewController(EqualizerFragment.newInstance(), "EqualizerFragment"), 250);
break;
case NavigationEventRelay.NavigationEvent.Type.SETTINGS_SELECTED:
delayHandler.postDelayed(() -> multiSheetEventRelay.sendEvent(new MultiSheetEventRelay.MultiSheetEvent(MultiSheetEventRelay.MultiSheetEvent.Action.HIDE, MultiSheetView.Sheet.FIRST)), 100);
delayHandler.postDelayed(() -> pushViewController(SettingsParentFragment.newInstance(R.xml.settings_headers, R.string.settings), "Settings Fragment"), 250);
break;
case NavigationEventRelay.NavigationEvent.Type.SUPPORT_SELECTED:
delayHandler.postDelayed(() -> multiSheetEventRelay.sendEvent(new MultiSheetEventRelay.MultiSheetEvent(MultiSheetEventRelay.MultiSheetEvent.Action.HIDE, MultiSheetView.Sheet.FIRST)), 100);
delayHandler.postDelayed(() -> pushViewController(SettingsParentFragment.newInstance(R.xml.settings_support, R.string.pref_title_support), "Support Fragment"), 250);
break;
case NavigationEventRelay.NavigationEvent.Type.PLAYLIST_SELECTED:
delayHandler.postDelayed(() -> pushViewController(PlaylistDetailFragment.newInstance((Playlist) navigationEvent.data), "PlaylistDetailFragment"), 250);
break;
case NavigationEventRelay.NavigationEvent.Type.GO_TO_ARTIST:
multiSheetView.goToSheet(MultiSheetView.Sheet.NONE);
AlbumArtist albumArtist = (AlbumArtist) navigationEvent.data;
delayHandler.postDelayed(() -> {
popToRootViewController();
pushViewController(ArtistDetailFragment.newInstance(albumArtist, null), "ArtistDetailFragment");
}, 250);
break;
case NavigationEventRelay.NavigationEvent.Type.GO_TO_ALBUM:
multiSheetView.goToSheet(MultiSheetView.Sheet.NONE);
Album album = (Album) navigationEvent.data;
delayHandler.postDelayed(() -> {
popToRootViewController();
pushViewController(AlbumDetailFragment.newInstance(album, null), "AlbumDetailFragment");
}, 250);
break;
case NavigationEventRelay.NavigationEvent.Type.GO_TO_GENRE:
multiSheetView.goToSheet(MultiSheetView.Sheet.NONE);
Genre genre = (Genre) navigationEvent.data;
delayHandler.postDelayed(() -> {
popToRootViewController();
pushViewController(GenreDetailFragment.newInstance(genre), "GenreDetailFragment");
}, 250);
break;
}
}));
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(MusicService.InternalIntents.SERVICE_CONNECTED);
intentFilter.addAction(MusicService.InternalIntents.QUEUE_CHANGED);
disposables.add(RxBroadcast.fromBroadcast(getContext(), intentFilter).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(intent -> toggleBottomSheetVisibility(true, true)));
DrawerLockManager.getInstance().setDrawerLockController(this);
}
use of com.simplecity.amp_library.model.AlbumArtist in project Shuttle by timusus.
the class SearchPresenter method onAlbumArtistOverflowClicked.
@Override
public void onAlbumArtistOverflowClicked(View v, AlbumArtist albumArtist) {
PopupMenu menu = new PopupMenu(v.getContext(), v);
menu.inflate(R.menu.menu_artist);
menu.setOnMenuItemClickListener(MenuUtils.getAlbumArtistClickListener(v.getContext(), albumArtist, taggerDialog -> {
SearchView searchView = getView();
if (searchView != null) {
searchView.showTaggerDialog(taggerDialog);
}
}, deleteDialog -> {
SearchView searchView = getView();
if (searchView != null) {
searchView.showDeleteDialog(deleteDialog);
}
}, null, () -> {
SearchView searchView = getView();
if (searchView != null) {
searchView.showUpgradeDialog();
}
}));
menu.show();
}
use of com.simplecity.amp_library.model.AlbumArtist in project Shuttle by timusus.
the class VoiceSearchActivity method searchAndPlaySongs.
private void searchAndPlaySongs() {
DataManager.getInstance().getAlbumArtistsRelay().first(Collections.emptyList()).flatMapObservable(Observable::fromIterable).filter(albumArtist -> albumArtist.name.toLowerCase(Locale.getDefault()).contains(filterString.toLowerCase())).flatMapSingle(AlbumArtist::getSongsSingle).map(songs -> {
Collections.sort(songs, (a, b) -> a.getAlbumArtist().compareTo(b.getAlbumArtist()));
Collections.sort(songs, (a, b) -> a.getAlbum().compareTo(b.getAlbum()));
Collections.sort(songs, (a, b) -> ComparisonUtils.compareInt(a.track, b.track));
Collections.sort(songs, (a, b) -> ComparisonUtils.compareInt(a.discNumber, b.discNumber));
return songs;
});
// Search for album-artists, albums & songs matching our filter. Then, create an Observable emitting List<Song> for each type of result.
// Then we concat the results, and return the first one which is non-empty. Order is important here, we want album-artist first, if it's
// available, then albums, then songs.
Observable.concat(// If we have an album artist matching our query, then play the songs by that album artist
DataManager.getInstance().getAlbumArtistsRelay().first(Collections.emptyList()).flatMapObservable(Observable::fromIterable).filter(albumArtist -> albumArtist.name.toLowerCase(Locale.getDefault()).contains(filterString.toLowerCase())).flatMapSingle(AlbumArtist::getSongsSingle).map(songs -> {
Collections.sort(songs, (a, b) -> a.getAlbumArtist().compareTo(b.getAlbumArtist()));
Collections.sort(songs, (a, b) -> a.getAlbum().compareTo(b.getAlbum()));
Collections.sort(songs, (a, b) -> ComparisonUtils.compareInt(a.track, b.track));
Collections.sort(songs, (a, b) -> ComparisonUtils.compareInt(a.discNumber, b.discNumber));
return songs;
}), // If we have an album matching our query, then play the songs from that album
DataManager.getInstance().getAlbumsRelay().first(Collections.emptyList()).flatMapObservable(Observable::fromIterable).filter(album -> containsIgnoreCase(album.name, filterString) || containsIgnoreCase(album.name, filterString) || (Stream.of(album.artists).anyMatch(artist -> containsIgnoreCase(artist.name, filterString))) || containsIgnoreCase(album.albumArtistName, filterString)).flatMapSingle(Album::getSongsSingle).map(songs -> {
Collections.sort(songs, (a, b) -> a.getAlbum().compareTo(b.getAlbum()));
Collections.sort(songs, (a, b) -> ComparisonUtils.compareInt(a.track, b.track));
Collections.sort(songs, (a, b) -> ComparisonUtils.compareInt(a.discNumber, b.discNumber));
return songs;
}), // If have a song, play that song, as well as others from the same album.
DataManager.getInstance().getSongsRelay().first(Collections.emptyList()).flatMapObservable(Observable::fromIterable).filter(song -> containsIgnoreCase(song.name, filterString) || containsIgnoreCase(song.albumName, filterString) || containsIgnoreCase(song.artistName, filterString) || containsIgnoreCase(song.albumArtistName, filterString)).flatMapSingle(song -> song.getAlbum().getSongsSingle().map(songs -> {
Collections.sort(songs, (a, b) -> ComparisonUtils.compareInt(a.track, b.track));
Collections.sort(songs, (a, b) -> ComparisonUtils.compareInt(a.discNumber, b.discNumber));
position = songs.indexOf(song);
return songs;
}))).filter(songs -> !songs.isEmpty()).firstOrError().observeOn(AndroidSchedulers.mainThread()).subscribe(songs -> {
if (songs != null) {
MusicUtils.playAll(songs, position, true, (String message) -> Toast.makeText(this, message, Toast.LENGTH_SHORT).show());
startActivity(new Intent(this, MainActivity.class));
}
finish();
}, error -> {
LogUtils.logException(TAG, "Error attempting to playAll()", error);
startActivity(new Intent(this, MainActivity.class));
finish();
});
}
use of com.simplecity.amp_library.model.AlbumArtist in project Shuttle by timusus.
the class TaggerDialog method onCreate.
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Serializable model = getArguments().getSerializable(ARG_MODEL);
if (model instanceof AlbumArtist) {
albumArtist = (AlbumArtist) model;
originalSongPaths = Stream.of(albumArtist.albums).flatMap(value -> Stream.of(value.paths)).toList();
showAlbum = false;
showTrack = false;
} else if (model instanceof Album) {
album = (Album) model;
originalSongPaths = album.paths;
showTrack = false;
} else if (model instanceof Song) {
song = (Song) model;
originalSongPaths.add(song.path);
}
if (originalSongPaths == null || originalSongPaths.isEmpty()) {
dismiss();
// Todo: refine & extract
Toast.makeText(getContext(), R.string.tag_retrieve_error, Toast.LENGTH_LONG).show();
}
}
use of com.simplecity.amp_library.model.AlbumArtist in project Shuttle by timusus.
the class Operators method albumsToAlbumArtists.
public static List<AlbumArtist> albumsToAlbumArtists(List<Album> albums) {
HashMap<String, AlbumArtist> albumArtistMap = new HashMap<>();
for (Album album : albums) {
// Create an album-artist representing the album-artist this album belongs to
AlbumArtist albumArtist = album.getAlbumArtist();
// Check if there's already an equivalent album-artist in our albumArtistMap
AlbumArtist oldAlbumArtist = albumArtistMap.get(albumArtist.name);
if (oldAlbumArtist != null) {
// Add this album to the album artist's albums
if (!oldAlbumArtist.albums.contains(album)) {
oldAlbumArtist.albums.add(album);
}
} else {
albumArtistMap.put(albumArtist.name, albumArtist);
}
}
return new ArrayList<>(albumArtistMap.values());
}
Aggregations