X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2FSaveTransactionTask.java;h=6ebfc511e0f1151a3e8880f9b9bdf5ae0e99e266;hp=ae15b446d7853041942af78762daf7916a644fdc;hb=8b2a83f10265f8c8e8044b8dd990337283834afd;hpb=1976f73e2af2e2085eb881826147b6a5ef1a9257
diff --git a/app/src/main/java/net/ktnx/mobileledger/SaveTransactionTask.java b/app/src/main/java/net/ktnx/mobileledger/SaveTransactionTask.java
index ae15b446..6ebfc511 100644
--- a/app/src/main/java/net/ktnx/mobileledger/SaveTransactionTask.java
+++ b/app/src/main/java/net/ktnx/mobileledger/SaveTransactionTask.java
@@ -1,3 +1,20 @@
+/*
+ * Copyright © 2018 Damyan Ivanov.
+ * This file is part of Mobile-Ledger.
+ * Mobile-Ledger is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * Mobile-Ledger is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mobile-Ledger. If not, see .
+ */
+
package net.ktnx.mobileledger;
import android.content.SharedPreferences;
@@ -25,6 +42,7 @@ class SaveTransactionTask extends AsyncTask {
private String session;
private String backend_url;
private LedgerTransaction ltr;
+ protected String error;
private SharedPreferences pref;
void setPref(SharedPreferences pref) {
@@ -120,23 +138,27 @@ class SaveTransactionTask extends AsyncTask {
@Override
protected Void doInBackground(LedgerTransaction... ledgerTransactions) {
- backend_url = pref.getString("backend_url", "");
- ltr = ledgerTransactions[0];
+ error = null;
try {
+ backend_url = pref.getString("backend_url", "");
+ ltr = ledgerTransactions[0];
+
int tried = 0;
- while (! send_ok() ) {
+ while (!send_ok()) {
try {
tried++;
if (tried >= 2)
throw new IOException(String.format("aborting after %d tries", tried));
sleep(100);
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e) {
e.printStackTrace();
}
}
}
- catch (IOException e) {
+ catch (Exception e) {
e.printStackTrace();
+ error = e.getMessage();
}
return null;
@@ -145,6 +167,6 @@ class SaveTransactionTask extends AsyncTask {
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
- task_callback.done();
+ task_callback.done(error);
}
}