Merge "Fix a race condition when switching between settings panels" into jb-mr1.1-dev

This commit is contained in:
Amith Yamasani
2012-11-15 12:21:31 -08:00
committed by Android (Google) Code Review

View File

@@ -26,6 +26,7 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.UserInfo; import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
@@ -477,6 +478,7 @@ public class UserSettings extends SettingsPreferenceFragment
} }
private void loadIconsAsync(List<Integer> missingIcons) { private void loadIconsAsync(List<Integer> missingIcons) {
final Resources resources = getResources();
new AsyncTask<List<Integer>, Void, Void>() { new AsyncTask<List<Integer>, Void, Void>() {
@Override @Override
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
@@ -485,17 +487,16 @@ public class UserSettings extends SettingsPreferenceFragment
@Override @Override
protected Void doInBackground(List<Integer>... values) { protected Void doInBackground(List<Integer>... values) {
if (getActivity() == null) return null;
for (int userId : values[0]) { for (int userId : values[0]) {
Bitmap bitmap = mUserManager.getUserIcon(userId); Bitmap bitmap = mUserManager.getUserIcon(userId);
Drawable d = new BitmapDrawable(getResources(), bitmap); Drawable d = new BitmapDrawable(resources, bitmap);
mUserIcons.append(userId, d); mUserIcons.append(userId, d);
} }
return null; return null;
} }
}.execute(missingIcons); }.execute(missingIcons);
} }
private void assignProfilePhoto(final UserInfo user) { private void assignProfilePhoto(final UserInfo user) {
if (!Utils.copyMeProfilePhoto(getActivity(), user)) { if (!Utils.copyMeProfilePhoto(getActivity(), user)) {
assignDefaultPhoto(user); assignDefaultPhoto(user);