use of android.support.v7.view.ActionMode in project Shuttle by timusus.
the class AlbumArtistFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if (recyclerView == null) {
int spanCount = SettingsManager.getInstance().getArtistColumnCount(getResources());
layoutManager = new GridLayoutManager(getContext(), spanCount);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (albumArtistAdapter.items.get(position) instanceof EmptyView) {
return spanCount;
}
return 1;
}
});
recyclerView = (FastScrollRecyclerView) inflater.inflate(R.layout.fragment_recycler, container, false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new GridDividerDecoration(getResources(), 4, true));
recyclerView.setRecyclerListener(this);
recyclerView.setAdapter(albumArtistAdapter);
actionMode = null;
themeUIComponents();
}
return recyclerView;
}
use of android.support.v7.view.ActionMode in project Shuttle by timusus.
the class AlbumFragment method onCreateView.
@SuppressLint("NewApi")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (recyclerView == null) {
int spanCount = SettingsManager.getInstance().getAlbumColumnCount(getResources());
layoutManager = new GridLayoutManager(getContext(), spanCount);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (albumAdapter.items.get(position) instanceof EmptyView) {
return spanCount;
}
return 1;
}
});
recyclerView = (FastScrollRecyclerView) inflater.inflate(R.layout.fragment_recycler, container, false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new GridDividerDecoration(getResources(), 4, true));
recyclerView.setRecyclerListener(this);
recyclerView.setAdapter(albumAdapter);
actionMode = null;
themeUIComponents();
}
return recyclerView;
}
use of android.support.v7.view.ActionMode in project HoloEverywhere by Prototik.
the class ActionBarContextView method initForMode.
public void initForMode(final ActionMode mode) {
if (mClose == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
mClose = inflater.inflate(R.layout.abc_action_mode_close_item, this, false);
addView(mClose);
} else if (mClose.getParent() == null) {
addView(mClose);
}
View closeButton = mClose.findViewById(R.id.action_mode_close_button);
closeButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mode.finish();
}
});
final MenuBuilder menu = (MenuBuilder) mode.getMenu();
if (mActionMenuPresenter != null) {
mActionMenuPresenter.dismissPopupMenus();
}
mActionMenuPresenter = new ActionMenuPresenter(getContext());
mActionMenuPresenter.setReserveOverflow(true);
final ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.FILL_PARENT);
if (!mSplitActionBar) {
menu.addMenuPresenter(mActionMenuPresenter);
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
mMenuView.setBackgroundDrawable(null);
addView(mMenuView, layoutParams);
} else {
// Allow full screen width in split mode.
mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
// No limit to the item count; use whatever will fit.
mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
// Span the whole width
layoutParams.width = ViewGroup.LayoutParams.FILL_PARENT;
layoutParams.height = mContentHeight;
menu.addMenuPresenter(mActionMenuPresenter);
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
mMenuView.setBackgroundDrawable(mSplitBackground);
mSplitView.addView(mMenuView, layoutParams);
}
}
use of android.support.v7.view.ActionMode in project RoboBinding-gallery by RoboBinding.
the class ContextualActionModeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MemoryProductStore productStore = MemoryProductStore.getInstance();
productStore.reset();
presentationModel = new ContextualActionModePresentationModel(productStore);
initializeContentView(R.layout.activity_contextual_action_mode, presentationModel);
ListView productListView = (ListView) findViewById(R.id.productList);
productListView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
startSupportActionMode(new ActionMode.Callback() {
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
}
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
MenuBinder menuBinder = createMenuBinder(menu, getMenuInflater());
menuBinder.inflateAndBind(R.menu.contextual_action_mode, presentationModel);
return true;
}
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
return false;
}
});
return true;
}
});
}
use of android.support.v7.view.ActionMode in project Signal-Android by WhisperSystems.
the class ConversationListFragment method handleDeleteAllSelected.
private void handleDeleteAllSelected() {
int conversationsCount = getListAdapter().getBatchSelections().size();
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setIconAttribute(R.attr.dialog_alert_icon);
alert.setTitle(getActivity().getResources().getQuantityString(R.plurals.ConversationListFragment_delete_selected_conversations, conversationsCount, conversationsCount));
alert.setMessage(getActivity().getResources().getQuantityString(R.plurals.ConversationListFragment_this_will_permanently_delete_all_n_selected_conversations, conversationsCount, conversationsCount));
alert.setCancelable(true);
alert.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final Set<Long> selectedConversations = (getListAdapter()).getBatchSelections();
if (!selectedConversations.isEmpty()) {
new AsyncTask<Void, Void, Void>() {
private ProgressDialog dialog;
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(getActivity(), getActivity().getString(R.string.ConversationListFragment_deleting), getActivity().getString(R.string.ConversationListFragment_deleting_selected_conversations), true, false);
}
@Override
protected Void doInBackground(Void... params) {
DatabaseFactory.getThreadDatabase(getActivity()).deleteConversations(selectedConversations);
MessageNotifier.updateNotification(getActivity(), masterSecret);
return null;
}
@Override
protected void onPostExecute(Void result) {
dialog.dismiss();
if (actionMode != null) {
actionMode.finish();
actionMode = null;
}
}
}.execute();
}
}
});
alert.setNegativeButton(android.R.string.cancel, null);
alert.show();
}
Aggregations