]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java
migrate a bunch of globals to LiveData
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / ProfileDetailActivity.java
index ad7401de661079b75510f59eab70b5e4c6d79318..1568c65fa6d7512e19ba13d0d662fe44a2c6bd98 100644 (file)
@@ -26,6 +26,9 @@ import net.ktnx.mobileledger.model.MobileLedgerProfile;
 import net.ktnx.mobileledger.ui.profiles.ProfileDetailFragment;
 import net.ktnx.mobileledger.utils.Colors;
 
+import java.util.ArrayList;
+import java.util.Locale;
+
 import androidx.appcompat.app.ActionBar;
 import androidx.appcompat.widget.Toolbar;
 
@@ -45,12 +48,16 @@ public class ProfileDetailActivity extends CrashReportingActivity {
         final int index = getIntent().getIntExtra(ProfileDetailFragment.ARG_ITEM_ID, -1);
 
         if (index != -1) {
-            profile = Data.profiles.get(index);
-            if (profile == null) throw new AssertionError(
-                    String.format("Can't get profile " + "(index:%d) from the global list", index));
+            ArrayList<MobileLedgerProfile> profiles = Data.profiles.getValue();
+            if (profiles != null) {
+                profile = profiles.get(index);
+                if (profile == null) throw new AssertionError(
+                        String.format("Can't get profile " + "(index:%d) from the global list",
+                                index));
 
-            debug("profiles", String.format("Editing profile %s (%s); hue=%d", profile.getName(),
-                    profile.getUuid(), profile.getThemeId()));
+                debug("profiles", String.format(Locale.ENGLISH, "Editing profile %s (%s); hue=%d",
+                        profile.getName(), profile.getUuid(), profile.getThemeId()));
+            }
         }
 
         super.onCreate(savedInstanceState);