Search in sources :

Example 1 with EqualizerFragment

use of com.simplecity.amp_library.ui.screens.equalizer.EqualizerFragment 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.Companion.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.Companion.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.Companion.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.Companion.newInstance(genre), "GenreDetailFragment");
                }, 250);
                break;
        }
    }));
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(InternalIntents.SERVICE_CONNECTED);
    intentFilter.addAction(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) NavigationEventRelay(com.simplecity.amp_library.ui.screens.drawer.NavigationEventRelay) Bundle(android.os.Bundle) MiniPlayerFragment(com.simplecity.amp_library.ui.screens.miniplayer.MiniPlayerFragment) PlayerFragment(com.simplecity.amp_library.ui.screens.nowplaying.PlayerFragment) PlaylistDetailFragment(com.simplecity.amp_library.ui.screens.playlist.detail.PlaylistDetailFragment) SettingsParentFragment(com.simplecity.amp_library.ui.settings.SettingsParentFragment) AlbumDetailFragment(com.simplecity.amp_library.ui.screens.album.detail.AlbumDetailFragment) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) BindView(butterknife.BindView) DrawerLockController(com.simplecity.amp_library.ui.screens.drawer.DrawerLockController) UpNextView(com.simplecity.amp_library.ui.screens.upnext.UpNextView) Handler(android.os.Handler) QueueFragment(com.simplecity.amp_library.ui.screens.queue.QueueFragment) 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) DrawerProvider(com.simplecity.amp_library.ui.screens.drawer.DrawerProvider) ViewGroup(android.view.ViewGroup) SettingsManager(com.simplecity.amp_library.utils.SettingsManager) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) List(java.util.List) Nullable(android.support.annotation.Nullable) MiniPlayerLockManager(com.simplecity.amp_library.ui.screens.drawer.MiniPlayerLockManager) Context(android.content.Context) Album(com.simplecity.amp_library.model.Album) ButterKnife(butterknife.ButterKnife) NonNull(android.support.annotation.NonNull) ArtistDetailFragment(com.simplecity.amp_library.ui.screens.artist.detail.ArtistDetailFragment) Inject(javax.inject.Inject) MultiSheetEventRelay(com.simplecity.amp_library.ui.views.multisheet.MultiSheetEventRelay) GenreDetailFragment(com.simplecity.amp_library.ui.screens.genre.detail.GenreDetailFragment) SleepTimer(com.simplecity.amp_library.utils.SleepTimer) Toast(android.widget.Toast) PlayerPresenter(com.simplecity.amp_library.ui.screens.nowplaying.PlayerPresenter) DrawerLayout(android.support.v4.widget.DrawerLayout) MediaManager(com.simplecity.amp_library.playback.MediaManager) MultiSheetView(com.simplecity.multisheetview.ui.view.MultiSheetView) LayoutInflater(android.view.LayoutInflater) AndroidSupportInjection(dagger.android.support.AndroidSupportInjection) FolderFragment(com.simplecity.amp_library.ui.screens.folders.FolderFragment) InternalIntents(com.simplecity.amp_library.playback.constants.InternalIntents) DrawerLockManager(com.simplecity.amp_library.ui.screens.drawer.DrawerLockManager) MultiSheetSlideEventRelay(com.simplecity.amp_library.ui.views.multisheet.MultiSheetSlideEventRelay) Pair(android.support.v4.util.Pair) EqualizerFragment(com.simplecity.amp_library.ui.screens.equalizer.EqualizerFragment) 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)

Aggregations

Context (android.content.Context)1 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 Album (com.simplecity.amp_library.model.Album)1 AlbumArtist (com.simplecity.amp_library.model.AlbumArtist)1