Search in sources :

Example 1 with AlbumDetailFragment

use of com.simplecity.amp_library.ui.detail.AlbumDetailFragment 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);
}
Also used : R(com.simplecity.amp_library.R) Genre(com.simplecity.amp_library.model.Genre) Bundle(android.os.Bundle) SettingsParentFragment(com.simplecity.amp_library.ui.settings.SettingsParentFragment) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) BindView(butterknife.BindView) Handler(android.os.Handler) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) UnsafeAction(com.simplecity.amp_library.rx.UnsafeAction) LogUtils(com.simplecity.amp_library.utils.LogUtils) BackPressHandler(test.com.androidnavigation.fragment.BackPressHandler) Playlist(com.simplecity.amp_library.model.Playlist) IntentFilter(android.content.IntentFilter) Fragment(android.support.v4.app.Fragment) FragmentInfo(test.com.androidnavigation.fragment.FragmentInfo) CustomMultiSheetView(com.simplecity.amp_library.ui.views.multisheet.CustomMultiSheetView) RxBroadcast(com.cantrowitz.rxbroadcast.RxBroadcast) GenreDetailFragment(com.simplecity.amp_library.ui.detail.GenreDetailFragment) ViewGroup(android.view.ViewGroup) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Nullable(android.support.annotation.Nullable) ArtistDetailFragment(com.simplecity.amp_library.ui.detail.ArtistDetailFragment) Album(com.simplecity.amp_library.model.Album) ButterKnife(butterknife.ButterKnife) AlbumDetailFragment(com.simplecity.amp_library.ui.detail.AlbumDetailFragment) DrawerLockManager(com.simplecity.amp_library.ui.drawer.DrawerLockManager) NonNull(android.support.annotation.NonNull) DrawerLockController(com.simplecity.amp_library.ui.drawer.DrawerLockController) UpNextView(com.simplecity.amp_library.ui.views.UpNextView) Inject(javax.inject.Inject) MultiSheetEventRelay(com.simplecity.amp_library.ui.views.multisheet.MultiSheetEventRelay) SleepTimer(com.simplecity.amp_library.utils.SleepTimer) Toast(android.widget.Toast) DrawerLayout(android.support.v4.widget.DrawerLayout) MiniPlayerLockManager(com.simplecity.amp_library.ui.drawer.MiniPlayerLockManager) MultiSheetView(com.simplecity.multisheetview.ui.view.MultiSheetView) LayoutInflater(android.view.LayoutInflater) DrawerProvider(com.simplecity.amp_library.ui.drawer.DrawerProvider) NavigationEventRelay(com.simplecity.amp_library.ui.drawer.NavigationEventRelay) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) MusicService(com.simplecity.amp_library.playback.MusicService) Pair(android.support.v4.util.Pair) PlaylistDetailFragment(com.simplecity.amp_library.ui.detail.PlaylistDetailFragment) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) BaseNavigationController(test.com.androidnavigation.fragment.BaseNavigationController) FragmentTransaction(android.support.v4.app.FragmentTransaction) IntentFilter(android.content.IntentFilter) UnsafeAction(com.simplecity.amp_library.rx.UnsafeAction) Playlist(com.simplecity.amp_library.model.Playlist) MultiSheetEventRelay(com.simplecity.amp_library.ui.views.multisheet.MultiSheetEventRelay) Handler(android.os.Handler) BackPressHandler(test.com.androidnavigation.fragment.BackPressHandler) Album(com.simplecity.amp_library.model.Album) Genre(com.simplecity.amp_library.model.Genre) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist)

Example 2 with AlbumDetailFragment

use of com.simplecity.amp_library.ui.detail.AlbumDetailFragment in project Shuttle by timusus.

the class LibraryController method onAlbumClicked.

@Override
public void onAlbumClicked(Album album, View transitionView) {
    String transitionName = ViewCompat.getTransitionName(transitionView);
    AlbumDetailFragment detailFragment = AlbumDetailFragment.newInstance(album, transitionName);
    pushDetailFragment(detailFragment, transitionView);
}
Also used : AlbumDetailFragment(com.simplecity.amp_library.ui.detail.AlbumDetailFragment)

Aggregations

AlbumDetailFragment (com.simplecity.amp_library.ui.detail.AlbumDetailFragment)2 IntentFilter (android.content.IntentFilter)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 Fragment (android.support.v4.app.Fragment)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 Pair (android.support.v4.util.Pair)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 Toast (android.widget.Toast)1 BindView (butterknife.BindView)1 ButterKnife (butterknife.ButterKnife)1 RxBroadcast (com.cantrowitz.rxbroadcast.RxBroadcast)1 R (com.simplecity.amp_library.R)1 ShuttleApplication (com.simplecity.amp_library.ShuttleApplication)1 Album (com.simplecity.amp_library.model.Album)1