use of com.simplecity.amp_library.ui.modelviews.SelectableViewModel in project Shuttle by timusus.
the class AlbumFragment 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();
if (playlistMenuDisposable != null) {
playlistMenuDisposable.dispose();
}
playlistMenuDisposable = PlaylistUtils.createUpdatingPlaylistMenu(sub).subscribe();
contextualToolbar.setOnMenuItemClickListener(MenuUtils.getAlbumMenuClickListener(getContext(), () -> contextualToolbarHelper.getItems(), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> contextualToolbarHelper.finish()));
contextualToolbarHelper = new ContextualToolbarHelper<>(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);
}
});
}
}
use of com.simplecity.amp_library.ui.modelviews.SelectableViewModel 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.modelviews.SelectableViewModel in project Shuttle by timusus.
the class AlbumArtistFragment 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();
if (playlistMenuDisposable != null) {
playlistMenuDisposable.dispose();
}
playlistMenuDisposable = PlaylistUtils.createUpdatingPlaylistMenu(sub).subscribe();
contextualToolbar.setOnMenuItemClickListener(MenuUtils.getAlbumArtistMenuClickListener(getContext(), () -> contextualToolbarHelper.getItems(), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> contextualToolbarHelper.finish()));
contextualToolbarHelper = new ContextualToolbarHelper<>(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);
}
});
}
}
use of com.simplecity.amp_library.ui.modelviews.SelectableViewModel in project Shuttle by timusus.
the class SongFragment 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();
if (playlistMenuDisposable != null) {
playlistMenuDisposable.dispose();
}
playlistMenuDisposable = PlaylistUtils.createUpdatingPlaylistMenu(sub).subscribe();
contextualToolbarHelper = new ContextualToolbarHelper<>(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);
}
});
contextualToolbar.setOnMenuItemClickListener(MenuUtils.getSongMenuClickListener(getContext(), Single.fromCallable(() -> contextualToolbarHelper.getItems()), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> contextualToolbarHelper.finish()));
}
}
use of com.simplecity.amp_library.ui.modelviews.SelectableViewModel in project Shuttle by timusus.
the class BaseDetailFragment method setupContextualToolbar.
private void setupContextualToolbar() {
ContextualToolbar contextualToolbar = ContextualToolbar.findContextualToolbar(this);
if (contextualToolbar != null) {
contextualToolbar.setTransparentBackground(true);
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) {
if (adapter.items.contains(viewModel)) {
adapter.notifyItemChanged(position, 0);
} else if (horizontalRecyclerView.viewModelAdapter.items.contains(viewModel)) {
horizontalRecyclerView.viewModelAdapter.notifyItemChanged(position);
}
}
@Override
public void notifyDatasetChanged() {
adapter.notifyItemRangeChanged(0, adapter.items.size(), 0);
horizontalRecyclerView.viewModelAdapter.notifyItemRangeChanged(0, horizontalRecyclerView.viewModelAdapter.items.size(), 0);
}
}) {
@Override
public void start() {
super.start();
// Need to hide the collapsed text, as it overlaps the contextual toolbar
collapsingToolbarTextColor = toolbarLayout.getCollapsedTitleTextColor();
collapsingToolbarSubTextColor = toolbarLayout.getCollapsedSubTextColor();
toolbarLayout.setCollapsedTitleTextColor(0x01FFFFFF);
toolbarLayout.setCollapsedSubTextColor(0x01FFFFFF);
toolbar.setVisibility(View.GONE);
}
@Override
public void finish() {
if (toolbarLayout != null) {
toolbarLayout.setCollapsedTitleTextColor(collapsingToolbarTextColor);
toolbarLayout.setCollapsedSubTextColor(collapsingToolbarSubTextColor);
}
if (toolbar != null) {
toolbar.setVisibility(View.VISIBLE);
}
super.finish();
}
};
}
}
Aggregations