diff options
author | Amith Yamasani <yamasani@google.com> | 2012-11-14 16:23:40 -0800 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2012-11-14 16:23:40 -0800 |
commit | 5cdc93725152e838d3213ca6ed1db92ae40fd0e3 (patch) | |
tree | 3e38f4bbc38e03c6732fb20ff83fc52dbea2b860 /src/com/android/settings/users/UserSettings.java | |
parent | 42d976842081d3e40cdc68774573fedd90f21575 (diff) | |
download | packages_apps_Settings-5cdc93725152e838d3213ca6ed1db92ae40fd0e3.zip packages_apps_Settings-5cdc93725152e838d3213ca6ed1db92ae40fd0e3.tar.gz packages_apps_Settings-5cdc93725152e838d3213ca6ed1db92ae40fd0e3.tar.bz2 |
Fix a race condition when switching between settings panels
The fragment was removed while the images were being loaded, so the
activity was null. This fix holds on to the Resources object.
Bug: 7490425
Change-Id: Ic2d8dd3c620fc34ce8255104001e17b39f828601
Diffstat (limited to 'src/com/android/settings/users/UserSettings.java')
-rw-r--r-- | src/com/android/settings/users/UserSettings.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java index 632dfe5..dbaaf37 100644 --- a/src/com/android/settings/users/UserSettings.java +++ b/src/com/android/settings/users/UserSettings.java @@ -26,6 +26,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.UserInfo; +import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; @@ -477,6 +478,7 @@ public class UserSettings extends SettingsPreferenceFragment } private void loadIconsAsync(List<Integer> missingIcons) { + final Resources resources = getResources(); new AsyncTask<List<Integer>, Void, Void>() { @Override protected void onPostExecute(Void result) { @@ -485,17 +487,16 @@ public class UserSettings extends SettingsPreferenceFragment @Override protected Void doInBackground(List<Integer>... values) { - if (getActivity() == null) return null; for (int userId : values[0]) { Bitmap bitmap = mUserManager.getUserIcon(userId); - Drawable d = new BitmapDrawable(getResources(), bitmap); + Drawable d = new BitmapDrawable(resources, bitmap); mUserIcons.append(userId, d); } return null; } }.execute(missingIcons); - } + private void assignProfilePhoto(final UserInfo user) { if (!Utils.copyMeProfilePhoto(getActivity(), user)) { assignDefaultPhoto(user); |