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);
}
}
Aggregations