]> git.ktnx.net Git - mobile-ledger-staging.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/async/SendTransactionTask.java
include errors sending transaction in debug output
[mobile-ledger-staging.git] / app / src / main / java / net / ktnx / mobileledger / async / SendTransactionTask.java
index 5bd55be4d6c1e36e928cb0211a287bb46a519143..8720dc0d5fb747b75494dde69941b849a104c7f9 100644 (file)
@@ -63,8 +63,8 @@ public class SendTransactionTask extends AsyncTask<LedgerTransaction, Void, Void
     private String token;
     private String session;
     private LedgerTransaction transaction;
-    private MobileLedgerProfile mProfile;
-    private boolean simulate;
+    private final MobileLedgerProfile mProfile;
+    private final boolean simulate;
 
     public SendTransactionTask(TaskCallback callback, MobileLedgerProfile profile,
                                boolean simulate) {
@@ -147,8 +147,19 @@ public class SendTransactionTask extends AsyncTask<LedgerTransaction, Void, Void
                     case 201:
                         break;
                     case 400:
-                    case 405:
+                    case 405: {
+                        BufferedReader reader = new BufferedReader(new InputStreamReader(resp));
+                        String line;
+                        int count = 0;
+                        while (count <= 5) {
+                            line = reader.readLine();
+                            if (line == null)
+                                break;
+                            Logger.debug("network", line);
+                            count++;
+                        }
                         return false; // will cause a retry with the legacy method
+                    }
                     default:
                         BufferedReader reader = new BufferedReader(new InputStreamReader(resp));
                         String line = reader.readLine();
@@ -177,7 +188,9 @@ public class SendTransactionTask extends AsyncTask<LedgerTransaction, Void, Void
         if (token != null)
             params.addPair("_token", token);
 
-        SimpleDate transactionDate = transaction.getDate();
+        SimpleDate transactionDate = transaction.getDateIfAny();
+        if (transactionDate == null)
+            transactionDate = SimpleDate.today();
 
         params.addPair("date", Globals.formatLedgerDate(transactionDate));
         params.addPair("description", transaction.getDescription());
@@ -315,7 +328,7 @@ public class SendTransactionTask extends AsyncTask<LedgerTransaction, Void, Void
 
     public enum API {
         auto(0), html(-1), pre_1_15(-2), post_1_14(-3);
-        private static SparseArray<API> map = new SparseArray<>();
+        private static final SparseArray<API> map = new SparseArray<>();
 
         static {
             for (API item : API.values()) {