Bug 1317643 - Resolved issue where the avatar icon resets to default. r=maliu
authorSean Maltby <seanmaltby@gmail.com>
Sat, 21 Jan 2017 19:03:02 -0500
changeset 373263 a29f11fae37711a4d09557377286a8688e652334
parent 373262 139294baffa2bf634f8f91d77b6b14112ec3f331
child 373264 8b02cdbaa32e9a4deedb9cb7fe8eb8a5268c27c6
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaliu
bugs1317643
milestone54.0a1
Bug 1317643 - Resolved issue where the avatar icon resets to default. r=maliu When debug mode is toggled, hardRefresh() is called, removing and adding all preferences. However, profileAvatarTarget wasn't being updated with the new instance of profilePreference. This was resolved by moving the creation of profileAvatarTarget to refresh(), which is called in hardRefresh(). MozReview-Commit-ID: 8raarHbmR23
mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java
@@ -466,20 +466,16 @@ public class FxAccountStatusFragment
     FxAccountSyncStatusHelper.getInstance().startObserving(syncStatusDelegate);
 
     // Register a local broadcast receiver to get profile cached notification.
     final IntentFilter intentFilter = new IntentFilter();
     intentFilter.addAction(FxAccountConstants.ACCOUNT_PROFILE_JSON_UPDATED_ACTION);
     accountProfileInformationReceiver = new FxAccountProfileInformationReceiver();
     LocalBroadcastManager.getInstance(getActivity()).registerReceiver(accountProfileInformationReceiver, intentFilter);
 
-    // profilePreference is set during onCreate, so it's definitely not null here.
-    final float cornerRadius = getResources().getDimension(R.dimen.fxaccount_profile_image_width) / 2;
-    profileAvatarTarget = new PicassoPreferenceIconTarget(getResources(), profilePreference, cornerRadius);
-
     refresh();
   }
 
   @Override
   public void onPause() {
     super.onPause();
     FxAccountSyncStatusHelper.getInstance().stopObserving(syncStatusDelegate);
 
@@ -513,16 +509,20 @@ public class FxAccountStatusFragment
   protected void refresh() {
     // refresh is called from our onResume, which can happen before the owning
     // Activity tells us about an account (via our public
     // refresh(AndroidFxAccount) method).
     if (fxAccount == null) {
       throw new IllegalArgumentException("fxAccount must not be null");
     }
 
+    // profilePreference is set during onCreate, so it's definitely not null here.
+    final float cornerRadius = getResources().getDimension(R.dimen.fxaccount_profile_image_width) / 2;
+    profileAvatarTarget = new PicassoPreferenceIconTarget(getResources(), profilePreference, cornerRadius);
+
     updateProfileInformation();
     updateAuthServerPreference();
     updateSyncServerPreference();
 
     try {
       // There are error states determined by Android, not the login state
       // machine, and we have a chance to present these states here. We handle
       // them specially, since we can't surface these states as part of syncing,