From f1f59dc1ed26c2351dc31e55902ff8e4b5a6ed0e Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 2 Oct 2019 18:04:18 +0530 Subject: Add Spotless to regulate codestyle (#550) * Add Spotless to regulate codestyle * treewide: Run spotless * Add spotlessCheck to CI test Signed-off-by: Harsh Shandilya --- .../java/com/zeapo/pwdstore/git/GitAsyncTask.java | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java') 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 0f0cf508..3dd1cd94 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java @@ -3,10 +3,9 @@ package com.zeapo.pwdstore.git; import android.app.Activity; import android.app.ProgressDialog; import android.os.AsyncTask; - import com.zeapo.pwdstore.PasswordStore; import com.zeapo.pwdstore.R; - +import java.lang.ref.WeakReference; import org.eclipse.jgit.api.CommitCommand; import org.eclipse.jgit.api.GitCommand; import org.eclipse.jgit.api.PullCommand; @@ -17,9 +16,6 @@ import org.eclipse.jgit.api.StatusCommand; import org.eclipse.jgit.transport.PushResult; import org.eclipse.jgit.transport.RemoteRefUpdate; -import java.lang.ref.WeakReference; - - public class GitAsyncTask extends AsyncTask { private WeakReference activityWeakReference; private boolean finishOnEnd; @@ -27,7 +23,11 @@ public class GitAsyncTask extends AsyncTask { private ProgressDialog dialog; private GitOperation operation; - public GitAsyncTask(Activity activity, boolean finishOnEnd, boolean refreshListOnEnd, GitOperation operation) { + public GitAsyncTask( + Activity activity, + boolean finishOnEnd, + boolean refreshListOnEnd, + GitOperation operation) { this.activityWeakReference = new WeakReference<>(activity); this.finishOnEnd = finishOnEnd; this.refreshListOnEnd = refreshListOnEnd; @@ -41,7 +41,8 @@ public class GitAsyncTask extends AsyncTask { } protected void onPreExecute() { - this.dialog.setMessage(getActivity().getResources().getString(R.string.running_dialog_text)); + this.dialog.setMessage( + getActivity().getResources().getString(R.string.running_dialog_text)); this.dialog.setCancelable(false); this.dialog.show(); } @@ -58,8 +59,7 @@ public class GitAsyncTask extends AsyncTask { nbChanges = status.getChanged().size() + status.getMissing().size(); } else if (command instanceof CommitCommand) { // the previous status will eventually be used to avoid a commit - if (nbChanges == null || nbChanges > 0) - command.call(); + if (nbChanges == null || nbChanges > 0) command.call(); } else if (command instanceof PullCommand) { final PullResult result = ((PullCommand) command).call(); final RebaseResult rr = result.getRebaseResult(); @@ -79,12 +79,14 @@ public class GitAsyncTask extends AsyncTask { case REJECTED_REMOTE_CHANGED: case NON_EXISTING: case NOT_ATTEMPTED: - return activity.getString(R.string.git_push_generic_error) + rru.getStatus().name(); + return activity.getString(R.string.git_push_generic_error) + + rru.getStatus().name(); case REJECTED_OTHER_REASON: if ("non-fast-forward".equals(rru.getMessage())) { return activity.getString(R.string.git_push_other_error); } else { - return activity.getString(R.string.git_push_generic_error) + rru.getMessage(); + return activity.getString(R.string.git_push_generic_error) + + rru.getMessage(); } default: break; @@ -111,8 +113,7 @@ public class GitAsyncTask extends AsyncTask { // ignore } - if (result == null) - result = "Unexpected error"; + if (result == null) result = "Unexpected error"; if (!result.isEmpty()) { this.operation.onError(result); -- cgit v1.2.3