in particular, the ProfileThemedActivity doesn't call finish() when
there is no current profile, because this is exactly the case when the
app has just been installed and the main activity's introductory
interface needs to be shown
Data.observeProfile(this, this::onProfileChanged);
}
private void onProfileChanged(Profile profile) {
Data.observeProfile(this, this::onProfileChanged);
}
private void onProfileChanged(Profile profile) {
+ if (profile == null)
+ return;
+
DB.get()
.getAccountDAO()
.getAllWithAmounts(profile.getId())
DB.get()
.getAccountDAO()
.getAllWithAmounts(profile.getId())
* called when the current profile has changed
*/
private void onProfileChanged(@Nullable Profile newProfile) {
* called when the current profile has changed
*/
private void onProfileChanged(@Nullable Profile newProfile) {
- if (this.profile == null) {
- if (newProfile == null)
- return;
- }
- else {
+ if (this.profile != null) {
if (this.profile.equals(newProfile))
return;
}
if (this.profile.equals(newProfile))
return;
}
else
setTitle(R.string.app_name);
else
setTitle(R.string.app_name);
- int newProfileTheme = haveProfile ? newProfile.getTheme() : -1;
+ int newProfileTheme = haveProfile ? newProfile.getTheme() : Colors.DEFAULT_HUE_DEG;
if (newProfileTheme != Colors.profileThemeId) {
Logger.debug("profiles",
String.format(Locale.ENGLISH, "profile theme %d → %d", Colors.profileThemeId,
if (newProfileTheme != Colors.profileThemeId) {
Logger.debug("profiles",
String.format(Locale.ENGLISH, "profile theme %d → %d", Colors.profileThemeId,
Data.observeProfile(this, profile -> {
if (profile == null) {
Logger.debug(TAG, "No current profile, leaving");
Data.observeProfile(this, profile -> {
if (profile == null) {
Logger.debug(TAG, "No current profile, leaving");
profile = dao.getAnySync();
}
profile = dao.getAnySync();
}
- Logger.debug(TAG, String.format(Locale.ROOT, "Profile %d loaded. posting", profileId));
+ if (profile == null)
+ Logger.debug(TAG, "No profile could be loaded");
+ else
+ Logger.debug(TAG, String.format(Locale.ROOT, "Profile %d loaded. posting", profileId));
Data.postCurrentProfile(profile);
}
}
Data.postCurrentProfile(profile);
}
}