]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/model/Data.java
global function for formatting numbers (locale-aware)
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / model / Data.java
index f0ba846ec05d9271a7c4f390631cde6a9906c4e5..4d0e52a57eb2ecc09ff2fb8f34b097bf206f858b 100644 (file)
@@ -91,6 +91,10 @@ public final class Data {
         backgroundTasksRunning.postValue(cnt > 0);
     }
     public static void setCurrentProfile(@NonNull MobileLedgerProfile newProfile) {
+        MLDB.setOption(MLDB.OPT_PROFILE_UUID, newProfile.getUuid());
+        profile.setValue(newProfile);
+    }
+    public static void postCurrentProfile(@NonNull MobileLedgerProfile newProfile) {
         MLDB.setOption(MLDB.OPT_PROFILE_UUID, newProfile.getUuid());
         profile.postValue(newProfile);
     }
@@ -186,7 +190,10 @@ public final class Data {
         else
             currencySymbolPosition.setValue(Currency.Position.none);
     }
-
+    public static String formatNumber(float number) {
+        NumberFormat formatter = NumberFormat.getCurrencyInstance(locale.getValue());
+        return formatter.format(number);
+    }
     public static void observeProfile(LifecycleOwner lifecycleOwner,
                                       Observer<MobileLedgerProfile> observer) {
         profile.observe(lifecycleOwner, observer);
@@ -200,6 +207,7 @@ public final class Data {
         MobileLedgerProfile startupProfile = getProfile(profileUUID);
         if (startupProfile != null)
             setCurrentProfile(startupProfile);
+        Logger.debug("profile", "initProfile() returning " + startupProfile);
         return startupProfile;
     }