Search in sources :

Example 1 with ImportLocalRepoDialog

use of me.sheimi.sgit.dialogs.ImportLocalRepoDialog in project MGit by maks.

the class RepoListActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK)
        return;
    switch(requestCode) {
        case REQUEST_IMPORT_REPO:
            final String path = data.getExtras().getString(ExploreFileActivity.RESULT_PATH);
            File file = new File(path);
            File dotGit = new File(file, Repo.DOT_GIT_DIR);
            if (!dotGit.exists()) {
                showToastMessage(getString(R.string.error_no_repository));
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(R.string.dialog_comfirm_import_repo_title);
            builder.setMessage(R.string.dialog_comfirm_import_repo_msg);
            builder.setNegativeButton(R.string.label_cancel, new DummyDialogListener());
            builder.setPositiveButton(R.string.label_import, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Bundle args = new Bundle();
                    args.putString(ImportLocalRepoDialog.FROM_PATH, path);
                    ImportLocalRepoDialog rld = new ImportLocalRepoDialog();
                    rld.setArguments(args);
                    rld.show(getSupportFragmentManager(), "import-local-dialog");
                }
            });
            builder.show();
            break;
    }
}
Also used : AlertDialog(android.app.AlertDialog) ImportLocalRepoDialog(me.sheimi.sgit.dialogs.ImportLocalRepoDialog) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) DummyDialogListener(me.sheimi.sgit.dialogs.DummyDialogListener) File(java.io.File)

Aggregations

AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 Bundle (android.os.Bundle)1 File (java.io.File)1 DummyDialogListener (me.sheimi.sgit.dialogs.DummyDialogListener)1 ImportLocalRepoDialog (me.sheimi.sgit.dialogs.ImportLocalRepoDialog)1