+ int newProfileTheme = haveProfile ? profile.getThemeHue() : -1;
+ if (newProfileTheme != Colors.profileThemeId) {
+ Logger.debug("profiles",
+ String.format(Locale.ENGLISH, "profile theme %d → %d", Colors.profileThemeId,
+ newProfileTheme));
+ Colors.profileThemeId = newProfileTheme;
+ profileThemeChanged();
+ // profileThemeChanged would restart the activity, so no need to reload the
+ // data sets below
+ return;
+ }
+
+ findViewById(R.id.no_profiles_layout).setVisibility(haveProfile ? View.GONE : View.VISIBLE);
+ findViewById(R.id.pager_layout).setVisibility(haveProfile ? View.VISIBLE : View.VISIBLE);
+
+ mProfileListAdapter.notifyDataSetChanged();
+
+ Data.transactions.clear();
+ Logger.debug("transactions", "requesting list reload");
+ TransactionListViewModel.scheduleTransactionListReload();
+
+ if (haveProfile) {
+ profile.scheduleAccountListReload();
+
+ if (profile.isPostingPermitted()) {
+ mToolbar.setSubtitle(null);
+ fab.show();
+ }
+ else {
+ mToolbar.setSubtitle(R.string.profile_subtitle_read_only);
+ fab.hide();
+ }
+ }
+ else {
+ mToolbar.setSubtitle(null);
+ fab.hide();
+ }
+
+ updateLastUpdateTextFromDB();
+ }
+ private void updateLastUpdateDisplay(Date newValue) {
+ LinearLayout l = findViewById(R.id.transactions_last_update_layout);
+ TextView v = findViewById(R.id.transactions_last_update);
+ if (newValue == null) {
+ l.setVisibility(View.INVISIBLE);
+ Logger.debug("main", "no last update date :(");
+ }
+ else {
+ final String text = DateFormat.getDateTimeInstance()
+ .format(newValue);
+ v.setText(text);
+ l.setVisibility(View.VISIBLE);
+ Logger.debug("main", String.format("Date formatted: %s", text));
+ }
+
+ scheduleDataRetrievalIfStale(newValue);
+ }
+ private void profileThemeChanged() {
+ storeThemeIdInPrefs(profile.getThemeHue());