- Data.ledgerTitle.addObserver(new Observer() {
- @Override
- public void update(Observable o, Object arg) {
- runOnUiThread(() -> {
- String title = Data.ledgerTitle.get();
- if (title == null)
- toolbar.setSubtitle("");
- else
- toolbar.setSubtitle(title);
- });
+ findViewById(R.id.main_app_layout).setVisibility(View.VISIBLE);
+ findViewById(R.id.no_profiles_layout).setVisibility(View.GONE);
+
+ 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();