+ findViewById(R.id.nav_profile_list).setMinimumHeight(
+ (int) (getResources().getDimension(R.dimen.thumb_row_height) * newList.size()));
+
+ debug("profiles", "profile list changed");
+ mProfileListAdapter.notifyDataSetChanged();
+
+ createShortcuts(newList);
+ }
+ /**
+ * called when the current profile has changed
+ */
+ private void onProfileChanged(MobileLedgerProfile profile) {
+ boolean haveProfile = profile != null;
+
+ if (haveProfile)
+ setTitle(profile.getName());
+ else
+ setTitle(R.string.app_name);
+
+ if (this.profile != null)
+ this.profile.getAccounts()
+ .removeObservers(this);
+
+ this.profile = profile;
+
+ int newProfileTheme = haveProfile ? profile.getThemeHue() : -1;
+ if (newProfileTheme != Colors.profileThemeId) {
+ 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();
+ 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);
+ debug("main", "no last update date :(");
+ }
+ else {
+ final String text = DateFormat.getDateTimeInstance()
+ .format(newValue);
+ v.setText(text);
+ l.setVisibility(View.VISIBLE);
+ debug("main", String.format("Date formatted: %s", text));
+ }
+
+ scheduleDataRetrievalIfStale(newValue);