]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
replace hollow switch with a simple if
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / async / RetrieveTransactionsTask.java
index db8f8de76a9b7b4d328b4f82b48e636bcebefa60..ef6eb8172c0598f3088af2c5481be4073042862f 100644 (file)
@@ -159,12 +159,8 @@ public class RetrieveTransactionsTask
         HttpURLConnection http = NetworkUtil.prepareConnection(profile, "journal");
         http.setAllowUserInteraction(false);
         publishProgress(progress);
-        switch (http.getResponseCode()) {
-            case 200:
-                break;
-            default:
-                throw new HTTPException(http.getResponseCode(), http.getResponseMessage());
-        }
+        if (http.getResponseCode() != 200)
+            throw new HTTPException(http.getResponseCode(), http.getResponseMessage());
 
         SQLiteDatabase db = App.getDatabase();
         try (InputStream resp = http.getInputStream()) {
@@ -206,7 +202,7 @@ public class RetrieveTransactionsTask
                                 // state of the database
                                 db.setTransactionSuccessful();
                                 db.endTransaction();
-                                Data.accounts.setList(accountList);
+                                profile.setAccounts(accountList);
                                 db.beginTransaction();
                                 continue;
                             }
@@ -527,16 +523,13 @@ public class RetrieveTransactionsTask
                 profile.deleteNotPresentAccounts(db);
                 throwIfCancelled();
                 db.setTransactionSuccessful();
-                listFilledOK = true;
             }
             finally {
                 db.endTransaction();
             }
         }
-        // should not be set in the DB transaction, because of a possible deadlock
-        // with the main and DbOpQueueRunner threads
-        if (listFilledOK)
-            Data.accounts.setList(accountList);
+
+        profile.setAccounts(accountList);
 
         return true;
     }