diff --git a/src/com/fsck/k9/activity/misc/ContactPictureLoader.java b/src/com/fsck/k9/activity/misc/ContactPictureLoader.java index 806e2a473..f123f134d 100644 --- a/src/com/fsck/k9/activity/misc/ContactPictureLoader.java +++ b/src/com/fsck/k9/activity/misc/ContactPictureLoader.java @@ -129,12 +129,12 @@ public class ContactPictureLoader { } else if (cancelPotentialWork(email, badge)) { // Query the contacts database in a background thread and try to load the contact // picture, if there is one. - ContactPictureRetrievalTask task = new ContactPictureRetrievalTask(badge); + ContactPictureRetrievalTask task = new ContactPictureRetrievalTask(badge, address); AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, calculateFallbackBitmap(address), task); badge.setImageDrawable(asyncDrawable); try { - task.exec(address.getAddress(), address.getPersonal()); + task.exec(); } catch (RejectedExecutionException e) { // We flooded the thread pool queue... use a fallback picture badge.setImageBitmap(calculateFallbackBitmap(address)); @@ -250,15 +250,16 @@ public class ContactPictureLoader { /** * Load a contact picture in a background thread. */ - class ContactPictureRetrievalTask extends AsyncTask { + class ContactPictureRetrievalTask extends AsyncTask { private final WeakReference mQuickContactBadgeReference; private Address mAddress; - ContactPictureRetrievalTask(QuickContactBadge badge) { + ContactPictureRetrievalTask(QuickContactBadge badge, Address address) { mQuickContactBadgeReference = new WeakReference(badge); + mAddress = new Address(address); } - public void exec(String... args) { + public void exec(Void... args) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args); } else { @@ -271,10 +272,8 @@ public class ContactPictureLoader { } @Override - protected Bitmap doInBackground(String... args) { - String email = args[0]; - String personal = args[1]; - mAddress = new Address(email, personal); + protected Bitmap doInBackground(Void... args) { + final String email = mAddress.getAddress(); final Uri x = mContactsHelper.getPhotoUri(email); Bitmap bitmap = null; if (x != null) { diff --git a/src/com/fsck/k9/mail/Address.java b/src/com/fsck/k9/mail/Address.java index f988a656f..3e8fb1111 100644 --- a/src/com/fsck/k9/mail/Address.java +++ b/src/com/fsck/k9/mail/Address.java @@ -47,12 +47,18 @@ public class Address { String mPersonal; + + public Address(Address address) { + mAddress = address.mAddress; + mPersonal = address.mPersonal; + } + public Address(String address, String personal) { this(address, personal, true); } public Address(String address) { - this(address, null); + this(address, null, true); } private Address(String address, String personal, boolean parse) {