]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/async/CommitAccountsTask.java
drop accounts.hidden and "hidden by star" handling
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / async / CommitAccountsTask.java
index 2c3d90f83947f9c7576624d718a84f9c218b4847..eb3dfbba51b0997424114ac55ba5a59782eebc80 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 Damyan Ivanov.
  * This file is part of MoLe.
  * MoLe is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
@@ -20,10 +20,10 @@ package net.ktnx.mobileledger.async;
 import android.database.sqlite.SQLiteDatabase;
 import android.os.AsyncTask;
 
+import net.ktnx.mobileledger.App;
 import net.ktnx.mobileledger.model.Data;
 import net.ktnx.mobileledger.model.LedgerAccount;
 import net.ktnx.mobileledger.utils.LockHolder;
-import net.ktnx.mobileledger.utils.MLDB;
 
 import java.util.ArrayList;
 
@@ -34,11 +34,11 @@ public class CommitAccountsTask
     protected ArrayList<LedgerAccount> doInBackground(CommitAccountsTaskParams... params) {
         Data.backgroundTaskStarted();
         ArrayList<LedgerAccount> newList = new ArrayList<>();
-        String profile = Data.profile.get().getUuid();
+        String profile = Data.profile.getValue().getUuid();
         try {
 
-            SQLiteDatabase db = MLDB.getDatabase();
-            db.beginTransaction();
+            SQLiteDatabase db = App.getDatabase();
+            db.beginTransactionNonExclusive();
             try {
                 try (LockHolder lh = params[0].accountList.lockForWriting()) {
                     for (int i = 0; i < params[0].accountList.size(); i++ ){
@@ -48,9 +48,6 @@ public class CommitAccountsTask
                         db.execSQL("UPDATE accounts SET hidden=? WHERE profile=? AND name=?",
                                 new Object[]{acc.isHiddenByStarToBe() ? 1 : 0, profile, acc.getName()
                                 });
-
-                        acc.setHiddenByStar(acc.isHiddenByStarToBe());
-                        if (!params[0].showOnlyStarred || !acc.isHiddenByStar()) newList.add(acc);
                     }
                     db.setTransactionSuccessful();
                 }