/*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 Damyan Ivanov.
* This file is part of MoLe.
* MoLe is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
@SuppressLint("Registered")
public class ProfileThemedActivity extends CrashReportingActivity {
protected MobileLedgerProfile mProfile;
+ private boolean themeSetUp = false;
+ private boolean mIgnoreProfileChange;
protected void setupProfileColors() {
- Colors.setupTheme(this, mProfile);
+ final int themeHue = (mProfile == null) ? -1 : mProfile.getThemeHue();
+
+ Colors.setupTheme(this, themeHue);
+
+ if (themeSetUp)
+ this.recreate();
+ themeSetUp = true;
+
+ Colors.profileThemeId = Data.retrieveCurrentThemeIdFromDb();
}
@Override
protected void onStart() {
protected void onCreate(@Nullable Bundle savedInstanceState) {
initProfile();
setupProfileColors();
+
+ mIgnoreProfileChange = true;
+ Data.observeProfile(this, profile -> {
+ if (!mIgnoreProfileChange) {
+ mProfile = profile;
+ setupProfileColors();
+ }
+
+ mIgnoreProfileChange = false;
+ });
+
super.onCreate(savedInstanceState);
}
protected void initProfile() {