+/*
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
package net.ktnx.mobileledger;
import android.content.SharedPreferences;
private String session;
private String backend_url;
private LedgerTransaction ltr;
+ protected String error;
private SharedPreferences pref;
void setPref(SharedPreferences pref) {
@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;
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
- task_callback.done();
+ task_callback.done(error);
}
}