createShortcuts(newList);
- Profile currentProfile = Data.getProfile();
- boolean currentProfilePresent = false;
+ final Profile currentProfile = Data.getProfile();
+ Profile replacementProfile = null;
if (currentProfile != null) {
for (Profile p : newList) {
if (p.getId() == currentProfile.getId()) {
- currentProfilePresent = true;
+ replacementProfile = p;
break;
}
}
}
- if (!currentProfilePresent) {
+
+ if (replacementProfile == null) {
Logger.debug(TAG, "Switching profile because the current is no longer available");
Data.setCurrentProfile(newList.get(0));
}
+ else {
+ Data.setCurrentProfile(replacementProfile);
+ }
}
/**
* 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;
}
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,