DRY refactoring
This commit is contained in:
parent
7b1204373d
commit
dbbb2305f7
1 changed files with 21 additions and 21 deletions
|
@ -11,6 +11,7 @@ import android.preference.PreferenceManager;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -38,6 +39,7 @@ import java.util.regex.Pattern;
|
||||||
// TODO move the messages to strings.xml
|
// TODO move the messages to strings.xml
|
||||||
|
|
||||||
public class GitActivity extends ActionBarActivity {
|
public class GitActivity extends ActionBarActivity {
|
||||||
|
private static final String TAG = "GitAct";
|
||||||
|
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
@ -604,34 +606,32 @@ public class GitActivity extends ActionBarActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
|
GitOperation op;
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case REQUEST_PULL:
|
case REQUEST_PULL:
|
||||||
try {
|
op = new PullOperation(localDir, activity).setCommand(hostname);
|
||||||
new PullOperation(localDir, activity)
|
|
||||||
.setCommand(hostname)
|
|
||||||
.executeAfterAuthentication(connectionMode, settings.getString("git_remote_username", "git"), new File(getFilesDir() + "/.ssh_key"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REQUEST_PUSH:
|
case REQUEST_PUSH:
|
||||||
try {
|
op = new PushOperation(localDir, activity).setCommand(hostname);
|
||||||
new PushOperation(localDir, activity)
|
break;
|
||||||
.setCommand(hostname)
|
|
||||||
.executeAfterAuthentication(connectionMode, settings.getString("git_remote_username", "git"), new File(getFilesDir() + "/.ssh_key"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} break;
|
|
||||||
case GitOperation.GET_SSH_KEY_FROM_CLONE:
|
case GitOperation.GET_SSH_KEY_FROM_CLONE:
|
||||||
|
op = new CloneOperation(localDir, activity).setCommand(hostname);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.e(TAG, "Operation not recognized : " + resultCode);
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new CloneOperation(localDir, activity)
|
op.executeAfterAuthentication(connectionMode, settings.getString("git_remote_username", "git"), new File(getFilesDir() + "/.ssh_key"));
|
||||||
.setCommand(hostname)
|
|
||||||
.executeAfterAuthentication(connectionMode, settings.getString("git_remote_username", "git"), new File(getFilesDir() + "/.ssh_key"));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue