diff options
author | zeapo <mohamed@zenadi.com> | 2017-08-11 09:31:36 +0200 |
---|---|---|
committer | zeapo <mohamed@zenadi.com> | 2017-08-11 09:31:36 +0200 |
commit | d6017be4eca37fafc7fb02ef7616fba6f086e106 (patch) | |
tree | f534ddb4cace902136b7c7e82c010994c826ceb1 /app/src | |
parent | 8ae59a4922a61ce3f57e8bce8fbacbc43c873e08 (diff) |
introduce onSuccess/onError
Diffstat (limited to 'app/src')
6 files changed, 22 insertions, 12 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java index 61e08dc2..c3f22a64 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java @@ -72,12 +72,12 @@ public class CloneOperation extends GitOperation { } @Override - public void onTaskEnded(String result) { + public void onError(String errorMessage) { new AlertDialog.Builder(callingActivity). setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)). setMessage("Error occured during the clone operation, " + callingActivity.getResources().getString(R.string.jgit_error_dialog_text) - + result + + errorMessage + "\nPlease check the FAQ for possible reasons why this error might occur."). setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java b/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java index a42e5d78..7fe31979 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java @@ -99,8 +99,10 @@ public class GitAsyncTask extends AsyncTask<GitCommand, Integer, String> { result = "Unexpected error"; if (!result.isEmpty()) { - this.operation.onTaskEnded(result); + this.operation.onError(result); } else { + this.operation.onSuccess(); + if (finishOnEnd) { this.activity.setResult(Activity.RESULT_OK); this.activity.finish(); diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java index 45189652..d78ca185 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java @@ -25,7 +25,6 @@ import com.zeapo.pwdstore.git.config.SshConfigSessionFactory; import com.zeapo.pwdstore.utils.PasswordRepository; import org.eclipse.jgit.api.GitCommand; -import org.eclipse.jgit.diff.Edit; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.transport.JschConfigSessionFactory; import org.eclipse.jgit.transport.SshSessionFactory; @@ -233,10 +232,13 @@ public abstract class GitOperation { } } - public void onTaskEnded(String result) { + /** + * Action to execute on error + */ + public void onError(String errorMessage) { new AlertDialog.Builder(callingActivity). setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)). - setMessage(callingActivity.getResources().getString(R.string.jgit_error_dialog_text) + result). + setMessage(callingActivity.getResources().getString(R.string.jgit_error_dialog_text) + errorMessage). setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { @@ -245,4 +247,10 @@ public abstract class GitOperation { } }).show(); } + + /** + * Action to execute on success + */ + public void onSuccess() { + } } diff --git a/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java index 9ab142c8..1a903aaf 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java @@ -45,12 +45,12 @@ public class PullOperation extends GitOperation { } @Override - public void onTaskEnded(String result) { + public void onError(String errorMessage) { new AlertDialog.Builder(callingActivity). setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)). setMessage("Error occured during the pull operation, " + callingActivity.getResources().getString(R.string.jgit_error_dialog_text) - + result + + errorMessage + "\nPlease check the FAQ for possible reasons why this error might occur."). setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override diff --git a/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java index 56e069d3..06eb6bb3 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java @@ -44,11 +44,11 @@ public class PushOperation extends GitOperation { } @Override - public void onTaskEnded(String result) { + public void onError(String errorMessage) { // TODO handle the "Nothing to push" case new AlertDialog.Builder(callingActivity). setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)). - setMessage(callingActivity.getString(R.string.jgit_error_push_dialog_text) + result). + setMessage(callingActivity.getString(R.string.jgit_error_push_dialog_text) + errorMessage). setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { diff --git a/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java index 089993d3..9dd43cb9 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java @@ -57,12 +57,12 @@ public class SyncOperation extends GitOperation { } @Override - public void onTaskEnded(String result) { + public void onError(String errorMessage) { new AlertDialog.Builder(callingActivity). setTitle(callingActivity.getResources().getString(R.string.jgit_error_dialog_title)). setMessage("Error occured during the sync operation, " + callingActivity.getResources().getString(R.string.jgit_error_dialog_text) - + result + + errorMessage + "\nPlease check the FAQ for possible reasons why this error might occur."). setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override |