Commit 6fc4a19d authored by Alice Wang's avatar Alice Wang Committed by Chromium LUCI CQ

[Android][Signin] Refresh SigninFragment UI only for target account update

This CL refreshes SigninFragment UI only for target account update in
ProfileDataCache. Prior to this CL, SigninFragment UI is refreshed for
all account updates in ProfileDataCache.

Bug: 1167672
Change-Id: I396eb4a9cccdadf2f5786f3ec5ee7184bf3ac528
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2635144Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845126}
parent 3747d7bb
...@@ -105,8 +105,8 @@ public abstract class SigninFragmentBase ...@@ -105,8 +105,8 @@ public abstract class SigninFragmentBase
private String mSelectedAccountName; private String mSelectedAccountName;
private boolean mIsDefaultAccountSelected; private boolean mIsDefaultAccountSelected;
private AccountsChangeObserver mAccountsChangedObserver; private final AccountsChangeObserver mAccountsChangedObserver;
private ProfileDataCache.Observer mProfileDataCacheObserver; private final ProfileDataCache.Observer mProfileDataCacheObserver;
private ProfileDataCache mProfileDataCache; private ProfileDataCache mProfileDataCache;
private List<String> mAccountNames; private List<String> mAccountNames;
private boolean mResumed; private boolean mResumed;
...@@ -170,7 +170,7 @@ public abstract class SigninFragmentBase ...@@ -170,7 +170,7 @@ public abstract class SigninFragmentBase
protected SigninFragmentBase() { protected SigninFragmentBase() {
mAccountsChangedObserver = this::triggerUpdateAccounts; mAccountsChangedObserver = this::triggerUpdateAccounts;
mProfileDataCacheObserver = (String accountId) -> updateProfileData(); mProfileDataCacheObserver = this::updateProfileData;
} }
/** The sign-in was refused. */ /** The sign-in was refused. */
...@@ -277,8 +277,9 @@ public abstract class SigninFragmentBase ...@@ -277,8 +277,9 @@ public abstract class SigninFragmentBase
// When a fragment that was in the FragmentManager backstack becomes visible again, the view // When a fragment that was in the FragmentManager backstack becomes visible again, the view
// will be recreated by onCreateView. Update the state of this recreated UI. // will be recreated by onCreateView. Update the state of this recreated UI.
if (mSelectedAccountName != null) updateProfileData(); if (mSelectedAccountName != null) {
updateProfileData(mSelectedAccountName);
}
return mView; return mView;
} }
...@@ -327,8 +328,10 @@ public abstract class SigninFragmentBase ...@@ -327,8 +328,10 @@ public abstract class SigninFragmentBase
mConsentTextTracker.setText(mView.getMoreButton(), R.string.more); mConsentTextTracker.setText(mView.getMoreButton(), R.string.more);
} }
private void updateProfileData() { private void updateProfileData(String accountEmail) {
if (mSelectedAccountName == null) return; if (!TextUtils.equals(accountEmail, mSelectedAccountName)) {
return;
}
DisplayableProfileData profileData = DisplayableProfileData profileData =
mProfileDataCache.getProfileDataOrDefault(mSelectedAccountName); mProfileDataCache.getProfileDataOrDefault(mSelectedAccountName);
mView.getAccountImageView().setImageDrawable(profileData.getImage()); mView.getAccountImageView().setImageDrawable(profileData.getImage());
...@@ -568,7 +571,7 @@ public abstract class SigninFragmentBase ...@@ -568,7 +571,7 @@ public abstract class SigninFragmentBase
mSelectedAccountName = accountName; mSelectedAccountName = accountName;
mIsDefaultAccountSelected = isDefaultAccount; mIsDefaultAccountSelected = isDefaultAccount;
mProfileDataCache.update(Collections.singletonList(mSelectedAccountName)); mProfileDataCache.update(Collections.singletonList(mSelectedAccountName));
updateProfileData(); updateProfileData(mSelectedAccountName);
AccountPickerDialogFragment accountPickerFragment = getAccountPickerDialogFragment(); AccountPickerDialogFragment accountPickerFragment = getAccountPickerDialogFragment();
if (accountPickerFragment != null) { if (accountPickerFragment != null) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment