use of com.simplecity.amp_library.ui.dialog.DeleteDialog 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);
}
});
}
use of com.simplecity.amp_library.ui.dialog.DeleteDialog 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