Source:
public void onItemLongClick(final ProjectData item, CheckableVH holder) { CharSequence[] items = new CharSequence[]{ getString(R.string.copy), getString(R.string.delete), getString(R.string.rename), getString(R.string.show_details), getString(R.string.upload_button) }; new AlertDialog.Builder(getActivity()) .setTitle(item.projectName) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: copyItems(new ArrayList<>(Collections.singletonList(item))); break; case 1: showDeleteAlert(new ArrayList<>(Collections.singletonList(item))); break; case 2: showRenameDialog(new ArrayList<>(Collections.singletonList(item))); break; case 3: ProjectDetailsFragment fragment = new ProjectDetailsFragment(); Bundle args = new Bundle(); args.putSerializable(ProjectDetailsFragment.SELECTED_PROJECT_KEY, item); fragment.setArguments(args); getFragmentManager().beginTransaction() .replace(R.id.fragment_container, fragment, ProjectDetailsFragment.TAG) .addToBackStack(ProjectDetailsFragment.TAG) .commit(); break; case 4: Project chosenProject; try { chosenProject = XstreamSerializer.getInstance().loadProject(item.getName(), getActivity()); if (Utils.isDefaultProject(chosenProject, getActivity())) { ToastUtil.showError(getActivity(), R.string.error_upload_default_project); } else { Intent intent = new Intent(getActivity(), ProjectUploadActivity.class) .putExtra(ProjectUploadActivity.PROJECT_NAME, item.getName()); startActivity(intent); } } catch (IOException | LoadingProjectException e) { Log.e(TAG, e.getMessage()); } break; default: dialog.dismiss(); } } }) .show(); }

Target:
public void onItemLongClick(final ProjectData item, CheckableVH holder) { CharSequence[] items = new CharSequence[]{ getString(R.string.copy), getString(R.string.delete), getString(R.string.rename), getString(R.string.show_details), getString(R.string.upload_button) }; new AlertDialog.Builder(getActivity()) .setTitle(item.projectName) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: copyItems(new ArrayList<>(Collections.singletonList(item))); break; case 1: showDeleteAlert(new ArrayList<>(Collections.singletonList(item))); break; case 2: showRenameDialog(new ArrayList<>(Collections.singletonList(item))); break; case 3: ProjectDetailsFragment fragment = new ProjectDetailsFragment(); Bundle args = new Bundle(); args.putSerializable(ProjectDetailsFragment.SELECTED_PROJECT_KEY, item); fragment.setArguments(args); getFragmentManager().beginTransaction() .replace(R.id.fragment_container, fragment, ProjectDetailsFragment.TAG) .addToBackStack(ProjectDetailsFragment.TAG) .commit(); break; case 4: try { Project chosenProject = XstreamSerializer.getInstance().loadProject(item.getName(), getActivity()); if (Utils.isDefaultProject(chosenProject, getActivity())) { ToastUtil.showError(getActivity(), R.string.error_upload_default_project); } else { Intent intent = new Intent(getActivity(), ProjectUploadActivity.class) .putExtra(ProjectUploadActivity.PROJECT_NAME, item.getName()); startActivity(intent); } } catch (IOException | LoadingProjectException e) { Log.e(TAG, e.getMessage()); } break; default: dialog.dismiss(); } } }) .show(); }