From 96d17e40f8437ee7143c0c9003cce7735a03bb39 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Tue, 18 Nov 2014 19:39:51 -0800 Subject: Improve setting of contact photos in InCallUI Add drawable caching in CallCardFragment so that we don't set the same drawable multiple times. Save and reuse the default contact photo and default conference photo to avoid possibly decoding them multiple times. Bug: 18373617 Change-Id: I54b925e6fc6f136f3d3ef27609fcdaf4c39a73dd --- .../src/com/android/incallui/ContactInfoCache.java | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'InCallUI/src/com/android/incallui/ContactInfoCache.java') diff --git a/InCallUI/src/com/android/incallui/ContactInfoCache.java b/InCallUI/src/com/android/incallui/ContactInfoCache.java index f8bd38d2b..49621695b 100644 --- a/InCallUI/src/com/android/incallui/ContactInfoCache.java +++ b/InCallUI/src/com/android/incallui/ContactInfoCache.java @@ -57,6 +57,9 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete private static ContactInfoCache sCache = null; + private Drawable mDefaultContactPhotoDrawable; + private Drawable mConferencePhotoDrawable; + public static synchronized ContactInfoCache getInstance(Context mContext) { if (sCache == null) { sCache = new ContactInfoCache(mContext.getApplicationContext()); @@ -316,12 +319,10 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete if (info.cachedPhoto != null) { photo = info.cachedPhoto; } else { - photo = context.getResources().getDrawable(R.drawable.img_no_image); - photo.setAutoMirrored(true); + photo = getDefaultContactPhotoDrawable(); } } else if (info.contactDisplayPhotoUri == null) { - photo = context.getResources().getDrawable(R.drawable.img_no_image); - photo.setAutoMirrored(true); + photo = getDefaultContactPhotoDrawable(); } else { cce.displayPhotoUri = info.contactDisplayPhotoUri; } @@ -491,6 +492,22 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete return name; } + public Drawable getDefaultContactPhotoDrawable() { + if (mDefaultContactPhotoDrawable == null) { + mDefaultContactPhotoDrawable = + mContext.getResources().getDrawable(R.drawable.img_no_image_automirrored); + } + return mDefaultContactPhotoDrawable; + } + + public Drawable getConferenceDrawable() { + if (mConferencePhotoDrawable == null) { + mConferencePhotoDrawable = + mContext.getResources().getDrawable(R.drawable.img_conference_automirrored); + } + return mConferencePhotoDrawable; + } + /** * Callback interface for the contact query. */ -- cgit v1.2.3