Search in sources :

Example 1 with Callback

use of com.simplecity.amp_library.utils.ContextualToolbarHelper.Callback in project Shuttle by timusus.

the class QueueFragment method setupContextualToolbar.

private void setupContextualToolbar() {
    cabToolbar.getMenu().clear();
    cabToolbar.inflateMenu(R.menu.context_menu_queue);
    final SubMenu sub = cabToolbar.getMenu().findItem(R.id.queue_add_to_playlist).getSubMenu();
    disposables.add(PlaylistUtils.createUpdatingPlaylistMenu(sub).subscribe());
    cabToolbar.setOnMenuItemClickListener(MenuUtils.getQueueMenuClickListener(getContext(), Single.fromCallable(() -> cabHelper.getItems()), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> {
        queuePresenter.removeFromQueue(cabHelper.getItems());
        cabHelper.finish();
    }, () -> cabHelper.finish()));
    cabHelper = new ContextualToolbarHelper<>(cabToolbar, new Callback() {

        @Override
        public void notifyItemChanged(int position, SelectableViewModel viewModel) {
            adapter.notifyItemChanged(position, 0);
        }

        @Override
        public void notifyDatasetChanged() {
            adapter.notifyItemRangeChanged(0, adapter.items.size(), 0);
        }
    });
}
Also used : 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) ItemTouchHelperCallback(com.simplecity.amp_library.ui.recyclerview.ItemTouchHelperCallback) Callback(com.simplecity.amp_library.utils.ContextualToolbarHelper.Callback) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) SubMenu(android.view.SubMenu)

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