diff options
| author | Zeapo <mohamed@zenadi.com> | 2014-08-08 18:46:35 +0100 |
|---|---|---|
| committer | Zeapo <mohamed@zenadi.com> | 2014-08-08 18:46:35 +0100 |
| commit | 42f1abfa76f06ee6d0a0e3bd5cc13b4afb1922a4 (patch) | |
| tree | e52d5f06b8ce3107c3accdb1321cbba34b026166 /app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java | |
| parent | 9db42440fb61f7e3b18f36532117f2247392dfe1 (diff) | |
| download | HardenedPass-42f1abfa76f06ee6d0a0e3bd5cc13b4afb1922a4.tar.gz HardenedPass-42f1abfa76f06ee6d0a0e3bd5cc13b4afb1922a4.zip | |
more refactoring and ability to pull from server
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java b/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java new file mode 100644 index 00000000..cc8938fb --- /dev/null +++ b/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java @@ -0,0 +1,52 @@ +package com.zeapo.pwdstore; + +import android.app.Activity; +import android.os.AsyncTask; +import android.util.Log; + +import org.eclipse.jgit.api.CloneCommand; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.GitCommand; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.TransportException; + + +public class GitAsyncTask extends AsyncTask<GitCommand, Integer, Integer> { + private Activity activity; + private boolean finishOnEnd; + public GitAsyncTask(Activity activity, boolean finishOnEnd) { + this.activity = activity; + this.finishOnEnd = finishOnEnd; + } + @Override + protected Integer doInBackground(GitCommand... cmd) { + int count = cmd.length; + Integer totalSize = 0; + for (int i = 0; i < count; i++) { + try { + cmd[i].call(); + } catch (JGitInternalException e) { + e.printStackTrace(); + return -99; + } catch (InvalidRemoteException e) { + e.printStackTrace(); + return -1; + } catch (TransportException e) { + e.printStackTrace(); + return -2; + } catch (Exception e) { + e.printStackTrace(); + } + totalSize++; + } + return totalSize; + } + + protected void onPostExecute(Integer result) { + Log.i("GIT_ASYNC", result + ""); + if (finishOnEnd) { + this.activity.finish(); + } + } +} |
