Search in sources :

Example 1 with QueuePresenter

use of com.simplecity.amp_library.ui.presenters.QueuePresenter in project Shuttle by timusus.

the class QueueFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_queue, container, false);
    unbinder = ButterKnife.bind(this, rootView);
    toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());
    toolbar.inflateMenu(R.menu.menu_queue);
    SubMenu sub = toolbar.getMenu().addSubMenu(0, MusicUtils.Defs.ADD_TO_PLAYLIST, 1, R.string.save_as_playlist);
    disposables.add(PlaylistUtils.createUpdatingPlaylistMenu(sub).subscribe());
    toolbar.setOnMenuItemClickListener(toolbarListener);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setRecyclerListener(new RecyclerListener());
    recyclerView.setAdapter(adapter);
    itemTouchHelper = new ItemTouchHelper(new ItemTouchHelperCallback((fromPosition, toPosition) -> adapter.moveItem(fromPosition, toPosition), MusicUtils::moveQueueItem, () -> {
    // Nothing to do
    }));
    itemTouchHelper.attachToRecyclerView(recyclerView);
    disposables.add(Aesthetic.get(getContext()).colorPrimary().subscribe(color -> {
        boolean isLight = Util.isColorLight(color);
        lineOne.setTextColor(isLight ? Color.BLACK : Color.WHITE);
        lineTwo.setTextColor(isLight ? Color.BLACK : Color.WHITE);
    }));
    // In landscape, we need to adjust the status bar's translation depending on the slide offset of the sheet
    if (ShuttleUtils.isLandscape()) {
        statusBarView.setTranslationY(ResourceUtils.toPixels(16));
        disposables.add(multiSheetSlideEventRelay.getEvents().filter(multiSheetEvent -> multiSheetEvent.sheet == MultiSheetView.Sheet.SECOND).filter(multiSheetEvent -> multiSheetEvent.slideOffset >= 0).subscribe(multiSheetEvent -> {
            statusBarView.setTranslationY((1 - multiSheetEvent.slideOffset) * ResourceUtils.toPixels(16));
        }));
    }
    setupContextualToolbar();
    queuePresenter = new QueuePresenter(requestManager, cabHelper);
    return rootView;
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) R(com.simplecity.amp_library.R) CompletionListUpdateCallbackAdapter(com.simplecityapps.recycler_adapter.adapter.CompletionListUpdateCallbackAdapter) Bundle(android.os.Bundle) SongView(com.simplecity.amp_library.ui.modelviews.SongView) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) BindView(butterknife.BindView) Song(com.simplecity.amp_library.model.Song) Aesthetic(com.afollestad.aesthetic.Aesthetic) RequestManager(com.bumptech.glide.RequestManager) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) ResourceUtils(com.simplecity.amp_library.utils.ResourceUtils) Unbinder(butterknife.Unbinder) ItemTouchHelperCallback(com.simplecity.amp_library.ui.recyclerview.ItemTouchHelperCallback) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) QueueView(com.simplecity.amp_library.ui.views.QueueView) SubMenu(android.view.SubMenu) ViewGroup(android.view.ViewGroup) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) TextView(android.widget.TextView) FragmentModule(com.simplecity.amp_library.dagger.module.FragmentModule) PermissionUtils(com.simplecity.amp_library.utils.PermissionUtils) Util(com.afollestad.aesthetic.Util) PlayerViewAdapter(com.simplecity.amp_library.ui.views.PlayerViewAdapter) Nullable(android.support.annotation.Nullable) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) ButterKnife(butterknife.ButterKnife) ViewModelAdapter(com.simplecityapps.recycler_adapter.adapter.ViewModelAdapter) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) Inject(javax.inject.Inject) Toast(android.widget.Toast) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) DeleteDialog(com.simplecity.amp_library.ui.dialog.DeleteDialog) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) TaggerDialog(com.simplecity.amp_library.tagger.TaggerDialog) MultiSheetView(com.simplecity.multisheetview.ui.view.MultiSheetView) LayoutInflater(android.view.LayoutInflater) ThemedStatusBarView(com.simplecity.amp_library.ui.views.ThemedStatusBarView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Color(android.graphics.Color) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) MultiSheetSlideEventRelay(com.simplecity.amp_library.ui.views.multisheet.MultiSheetSlideEventRelay) Toolbar(android.support.v7.widget.Toolbar) PlayerPresenter(com.simplecity.amp_library.ui.presenters.PlayerPresenter) QueuePresenter(com.simplecity.amp_library.ui.presenters.QueuePresenter) Callback(com.simplecity.amp_library.utils.ContextualToolbarHelper.Callback) QueuePresenter(com.simplecity.amp_library.ui.presenters.QueuePresenter) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) SubMenu(android.view.SubMenu) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SongView(com.simplecity.amp_library.ui.modelviews.SongView) BindView(butterknife.BindView) View(android.view.View) QueueView(com.simplecity.amp_library.ui.views.QueueView) TextView(android.widget.TextView) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) MultiSheetView(com.simplecity.multisheetview.ui.view.MultiSheetView) ThemedStatusBarView(com.simplecity.amp_library.ui.views.ThemedStatusBarView) ItemTouchHelperCallback(com.simplecity.amp_library.ui.recyclerview.ItemTouchHelperCallback)

Aggregations

Color (android.graphics.Color)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Toolbar (android.support.v7.widget.Toolbar)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 LayoutInflater (android.view.LayoutInflater)1 MenuItem (android.view.MenuItem)1 SubMenu (android.view.SubMenu)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1 BindView (butterknife.BindView)1 ButterKnife (butterknife.ButterKnife)1 Unbinder (butterknife.Unbinder)1 Aesthetic (com.afollestad.aesthetic.Aesthetic)1 Util (com.afollestad.aesthetic.Util)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 RequestManager (com.bumptech.glide.RequestManager)1