Search in sources :

Example 6 with ContextualToolbarHelper

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

the class SearchFragment method setupContextualToolbar.

private void setupContextualToolbar() {
    ContextualToolbar contextualToolbar = ContextualToolbar.findContextualToolbar(this);
    if (contextualToolbar != null) {
        contextualToolbar.getMenu().clear();
        contextualToolbar.inflateMenu(R.menu.context_menu_general);
        SubMenu sub = contextualToolbar.getMenu().findItem(R.id.addToPlaylist).getSubMenu();
        disposables.add(PlaylistUtils.createUpdatingPlaylistMenu(sub).subscribe());
        contextualToolbar.setOnMenuItemClickListener(MenuUtils.getSongMenuClickListener(getContext(), Single.defer(() -> Operators.reduceSongSingles(contextualToolbarHelper.getItems())), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> contextualToolbarHelper.finish()));
        contextualToolbarHelper = new ContextualToolbarHelper<Single<List<Song>>>(contextualToolbar, new ContextualToolbarHelper.Callback() {

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

            @Override
            public void notifyDatasetChanged() {
                adapter.notifyItemRangeChanged(0, adapter.items.size(), 0);
            }
        }) {

            @Override
            public void start() {
                super.start();
                toolbar.setVisibility(View.GONE);
            }

            @Override
            public void finish() {
                if (toolbar != null) {
                    toolbar.setVisibility(View.VISIBLE);
                }
                super.finish();
            }
        };
        searchPresenter.setContextualToolbarHelper(contextualToolbarHelper);
    }
}
Also used : R(com.simplecity.amp_library.R) BaseDetailFragment(com.simplecity.amp_library.ui.detail.BaseDetailFragment) Bundle(android.os.Bundle) SearchView(android.support.v7.widget.SearchView) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) BindView(butterknife.BindView) Song(com.simplecity.amp_library.model.Song) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) ResourceUtils(com.simplecity.amp_library.utils.ResourceUtils) ViewCompat(android.support.v4.view.ViewCompat) Transition(android.transition.Transition) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) RxSearchView(com.jakewharton.rxbinding2.support.v7.widget.RxSearchView) SubMenu(android.view.SubMenu) ViewGroup(android.view.ViewGroup) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) ContextualToolbarHost(com.simplecity.amp_library.ui.views.ContextualToolbarHost) Nullable(android.support.annotation.Nullable) ArtistDetailFragment(com.simplecity.amp_library.ui.detail.ArtistDetailFragment) Context(android.content.Context) Album(com.simplecity.amp_library.model.Album) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) ButterKnife(butterknife.ButterKnife) AlbumDetailFragment(com.simplecity.amp_library.ui.detail.AlbumDetailFragment) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) ViewModelAdapter(com.simplecityapps.recycler_adapter.adapter.ViewModelAdapter) NonNull(android.support.annotation.NonNull) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) PrefixHighlighter(com.simplecity.amp_library.format.PrefixHighlighter) Toast(android.widget.Toast) LoadingView(com.simplecity.amp_library.ui.modelviews.LoadingView) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) DeleteDialog(com.simplecity.amp_library.ui.dialog.DeleteDialog) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) TaggerDialog(com.simplecity.amp_library.tagger.TaggerDialog) BackpressureStrategy(io.reactivex.BackpressureStrategy) LayoutInflater(android.view.LayoutInflater) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TimeUnit(java.util.concurrent.TimeUnit) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) Glide(com.bumptech.glide.Glide) Toolbar(android.support.v7.widget.Toolbar) Pair(android.support.v4.util.Pair) TransitionInflater(android.transition.TransitionInflater) BaseFragment(com.simplecity.amp_library.ui.fragments.BaseFragment) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) Operators(com.simplecity.amp_library.utils.Operators) Collections(java.util.Collections) Song(com.simplecity.amp_library.model.Song) Single(io.reactivex.Single) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) SubMenu(android.view.SubMenu) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar)

Aggregations

Bundle (android.os.Bundle)6 Nullable (android.support.annotation.Nullable)6 LayoutInflater (android.view.LayoutInflater)6 MenuItem (android.view.MenuItem)6 SubMenu (android.view.SubMenu)6 View (android.view.View)6 ViewGroup (android.view.ViewGroup)6 R (com.simplecity.amp_library.R)6 UpgradeDialog (com.simplecity.amp_library.ui.dialog.UpgradeDialog)6 SelectableViewModel (com.simplecity.amp_library.ui.modelviews.SelectableViewModel)6 ContextualToolbar (com.simplecity.amp_library.ui.views.ContextualToolbar)6 ContextualToolbarHelper (com.simplecity.amp_library.utils.ContextualToolbarHelper)6 MenuUtils (com.simplecity.amp_library.utils.MenuUtils)6 PlaylistUtils (com.simplecity.amp_library.utils.PlaylistUtils)6 ViewModel (com.simplecityapps.recycler_adapter.model.ViewModel)6 Disposable (io.reactivex.disposables.Disposable)6 Toast (android.widget.Toast)5 MusicUtils (com.simplecity.amp_library.utils.MusicUtils)5 RecyclerListener (com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener)5 FastScrollRecyclerView (com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView)5