]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionModel.java
whitespace
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / NewTransactionModel.java
index b0241b1ae0aaa8ff06b8cd2037ce765defea6c35..9f5cd8c49108e622e288da4d066ad35e8e510bb4 100644 (file)
@@ -21,6 +21,7 @@ import android.annotation.SuppressLint;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+import androidx.lifecycle.LifecycleOwner;
 import androidx.lifecycle.LiveData;
 import androidx.lifecycle.MutableLiveData;
 import androidx.lifecycle.Observer;
@@ -28,7 +29,9 @@ import androidx.lifecycle.ViewModel;
 
 import net.ktnx.mobileledger.BuildConfig;
 import net.ktnx.mobileledger.model.Currency;
+import net.ktnx.mobileledger.model.Data;
 import net.ktnx.mobileledger.model.LedgerTransactionAccount;
+import net.ktnx.mobileledger.model.MobileLedgerProfile;
 import net.ktnx.mobileledger.utils.Logger;
 import net.ktnx.mobileledger.utils.Misc;
 
@@ -69,6 +72,10 @@ public class NewTransactionModel extends ViewModel {
      */
     private final HashMap<String, List<Item>> slots = new HashMap<>();
     private int checkHoldCounter = 0;
+    private Observer<MobileLedgerProfile> profileObserver = profile ->showCurrency.postValue(profile.getShowCommodityByDefault());
+    public void observeDataProfile(LifecycleOwner activity) {
+        Data.profile.observe(activity, profileObserver);
+    }
     void holdSubmittableChecks() {
         checkHoldCounter++;
     }
@@ -364,7 +371,7 @@ public class NewTransactionModel extends ViewModel {
                 if ((items.size() > 2) && (emptyItems.size() == 1)) {
                     List<Item> currItems = itemsForCurrency.getList(currName);
 
-                    if (currItems.size() == 1){
+                    if (currItems.size() == 1) {
                         Item item = emptyItems.get(0);
                         removeRow(item, adapter);
                     }