use of me.sheimi.sgit.dialogs.CheckoutDialog in project MGit by maks.
the class CommitsFragment method onActionItemClicked.
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
switch(menuItem.getItemId()) {
case R.id.action_mode_diff:
Integer[] items = mChosenItem.toArray(new Integer[0]);
if (items.length == 0) {
showToastMessage(R.string.alert_no_items_selected);
return true;
}
int item1, item2;
item1 = items[0];
if (items.length == 1) {
item2 = item1 + 1;
if (item2 == mCommitsListAdapter.getCount()) {
showToastMessage(R.string.alert_no_older_commits);
return true;
}
} else {
item2 = items[1];
}
int smaller = Math.min(item1, item2);
int larger = Math.max(item1, item2);
String oldCommit = mCommitsListAdapter.getItem(larger).getName();
String newCommit = mCommitsListAdapter.getItem(smaller).getName();
showDiff(actionMode, oldCommit, newCommit, false);
return true;
case R.id.action_mode_copy_commit:
{
if (mChosenItem.size() != 1) {
showToastMessage(R.string.alert_you_must_choose_one_commit_to_copy);
return true;
}
int item = mChosenItem.iterator().next();
String commit = mCommitsListAdapter.getItem(item).getName();
ClipData clip = ClipData.newPlainText("commit_to_copy", commit);
mClipboard.setPrimaryClip(clip);
showToastMessage(R.string.msg_commit_str_has_copied);
actionMode.finish();
return true;
}
case R.id.action_mode_checkout:
{
int item = mChosenItem.iterator().next();
String commit = mCommitsListAdapter.getItem(item).getName();
Bundle pathArg = new Bundle();
pathArg.putString(CheckoutDialog.BASE_COMMIT, commit);
pathArg.putSerializable(Repo.TAG, mRepo);
actionMode.finish();
CheckoutDialog ckd = new CheckoutDialog();
ckd.setArguments(pathArg);
ckd.show(getFragmentManager(), "rename-dialog");
break;
}
}
return false;
}
Aggregations