use of me.sheimi.sgit.dialogs.RenameBranchDialog in project MGit by maks.
the class BranchChooserActivity method onActionItemClicked.
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch(item.getItemId()) {
case R.id.action_mode_rename_branch:
Bundle pathArg = new Bundle();
pathArg.putString(RenameBranchDialog.FROM_COMMIT, mChosenCommit);
pathArg.putSerializable(Repo.TAG, mRepo);
mode.finish();
RenameBranchDialog rbd = new RenameBranchDialog();
rbd.setArguments(pathArg);
rbd.show(getFragmentManager(), "rename-dialog");
return true;
case R.id.action_mode_delete:
AlertDialog.Builder alert = new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(getString(R.string.dialog_branch_delete) + " " + mChosenCommit).setMessage(R.string.dialog_branch_delete_msg).setPositiveButton(R.string.label_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int commitType = Repo.getCommitType(mChosenCommit);
try {
switch(commitType) {
case Repo.COMMIT_TYPE_HEAD:
mRepo.getGit().branchDelete().setBranchNames(mChosenCommit).setForce(true).call();
break;
case Repo.COMMIT_TYPE_TAG:
mRepo.getGit().tagDelete().setTags(mChosenCommit).call();
break;
}
} catch (StopTaskException e) {
Log.e(LOGTAG, "can't delete " + mChosenCommit, e);
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(BranchChooserActivity.this, getString(R.string.cannot_delete_branch, mChosenCommit), Toast.LENGTH_LONG).show();
}
});
} catch (CannotDeleteCurrentBranchException e) {
Log.e(LOGTAG, "can't delete " + mChosenCommit, e);
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(BranchChooserActivity.this, getString(R.string.cannot_delete_current_branch, mChosenCommit), Toast.LENGTH_LONG).show();
}
});
} catch (GitAPIException e) {
Log.e(LOGTAG, "can't delete " + mChosenCommit, e);
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(BranchChooserActivity.this, getString(R.string.cannot_delete_branch, mChosenCommit), Toast.LENGTH_LONG).show();
}
});
}
refreshList();
}
}).setNegativeButton(R.string.label_cancel, null);
mode.finish();
alert.show();
return true;
default:
return false;
}
}
Aggregations