- final int index = getIntent().getIntExtra(ProfileDetailFragment.ARG_ITEM_ID, -1);
-
- if (index != -1) {
- 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.getId(), profile.getThemeHue()));
- }
- }
+ final long id = getIntent().getLongExtra(ProfileDetailFragment.ARG_ITEM_ID, -1);
+
+ if (id == -1)
+ throw new RuntimeException("Invalid or missing profile ID");
+
+ DB.get()
+ .getProfileDAO()
+ .getById(id)
+ .observe(this, this::setProfile);
+
+ int themeHue = getIntent().getIntExtra(ProfileDetailFragment.ARG_HUE, -1);