summaryrefslogtreecommitdiff
path: root/InCallUI/src/com/android
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-11-18 19:39:51 -0800
committerYorke Lee <yorkelee@google.com>2014-11-18 19:39:51 -0800
commit96d17e40f8437ee7143c0c9003cce7735a03bb39 (patch)
tree3ab30f8f3cef28f80626850b7a3849b4f0cceba5 /InCallUI/src/com/android
parent3e8ec5a893aa5286c280fc8113a9d72855874c04 (diff)
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
Diffstat (limited to 'InCallUI/src/com/android')
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java17
-rw-r--r--InCallUI/src/com/android/incallui/ContactInfoCache.java25
2 files changed, 34 insertions, 8 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 8aa8d2349..77ec17344 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -78,6 +78,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
private View mCallNumberAndLabel;
private ImageView mPhoto;
private TextView mElapsedTime;
+ private Drawable mPrimaryPhotoDrawable;
// Container view that houses the entire primary call card, including the call buttons
private View mPrimaryCallCardContainer;
@@ -111,6 +112,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
private int mVideoAnimationDuration;
+ private Drawable mDefaultContactPhoto;
+
private MaterialPalette mCurrentThemeColors;
@Override
@@ -599,9 +602,14 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
private void setDrawableToImageView(ImageView view, Drawable photo) {
if (photo == null) {
- photo = view.getResources().getDrawable(R.drawable.img_no_image);
- photo.setAutoMirrored(true);
+ photo = ContactInfoCache.getInstance(
+ view.getContext()).getDefaultContactPhotoDrawable();
+ }
+
+ if (mPrimaryPhotoDrawable == photo) {
+ return;
}
+ mPrimaryPhotoDrawable = photo;
final Drawable current = view.getDrawable();
if (current == null) {
@@ -622,8 +630,9 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
private Drawable getConferencePhoto(boolean canManageConference) {
Log.v(this, "canManageConferencePhoto: " + canManageConference);
- final int resId = canManageConference ? R.drawable.img_conference : R.drawable.img_phone;
- return getView().getResources().getDrawable(resId);
+ final ContactInfoCache cache = ContactInfoCache.getInstance(getView().getContext());
+ return canManageConference ? cache.getConferenceDrawable()
+ : cache.getDefaultContactPhotoDrawable();
}
/**
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.
*/