]> 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 40051dac68e4ef9155ea4036ba07fa0b7d56cd81..1568c65fa6d7512e19ba13d0d662fe44a2c6bd98 100644 (file)
@@ -26,6 +26,7 @@ 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;
@@ -47,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(Locale.ENGLISH, "Editing profile %s (%s); hue=%d",
                         profile.getName(), profile.getUuid(), profile.getThemeId()));
+            }
         }
 
         super.onCreate(savedInstanceState);