diff options
Diffstat (limited to 'src/com/android/contacts')
-rw-r--r-- | src/com/android/contacts/common/ContactPhotoManager.java | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/com/android/contacts/common/ContactPhotoManager.java b/src/com/android/contacts/common/ContactPhotoManager.java index 547b5623..6fa20f69 100644 --- a/src/com/android/contacts/common/ContactPhotoManager.java +++ b/src/com/android/contacts/common/ContactPhotoManager.java @@ -543,6 +543,8 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 { public abstract void getBitmapForContact(Uri photoUri, ImageView imgView, int widthHint, PhotoFetcherCallback cb); + public abstract void getBitmapForContact(long photoId, ImageView imgView, int widthHint, + PhotoFetcherCallback cb); /** * Calls {@link #loadPhoto(ImageView, Uri, boolean, boolean, DefaultImageRequest, * DefaultImageProvider)} with {@link #DEFAULT_AVATAR} and with the assumption, that @@ -917,13 +919,22 @@ class ContactPhotoManagerImpl extends ContactPhotoManager implements Callback { // formulate the contact bitmap request Request request = Request.createBitmapOnly(photoUri, widthHint, cb); - // check bitmap cache - boolean done = decodeContactBitmapFromCache(request); + getBitmapForContact(imgView, request); + } - // if not in cache, put request in loading queue + @Override + public void getBitmapForContact(long photoId, ImageView imgView, int widthHint, + PhotoFetcherCallback cb) { + if (photoId <= 0) return; + Request request = Request.createBitmapOnly(photoId, widthHint, cb); + getBitmapForContact(imgView, request); + } + + private void getBitmapForContact(ImageView imgView, Request request) { + boolean done = decodeContactBitmapFromCache(request); + // if not in cache, put request into loading queue if (!done) { - Request loadRequest = Request.createBitmapOnly(photoUri, widthHint, cb); - mPendingRequests.put(imgView, loadRequest); + mPendingRequests.put(imgView, request); if (!mPaused) { requestLoading(); } @@ -1737,6 +1748,21 @@ class ContactPhotoManagerImpl extends ContactPhotoManager implements Callback { return request; } + public static Request createBitmapOnly(long photoId, int requestedExtent, + PhotoFetcherCallback cb) { + return createBitmapOnly(photoId, requestedExtent, cb, null); + } + + public static Request createBitmapOnly(long photoId, int requestedExtent, + PhotoFetcherCallback cb, DefaultImageRequest defaultImageRequest) { + Request request = new Request(photoId, null, requestedExtent, false, false, null, + defaultImageRequest); + request.setBitmapOnly(); + request.mCallback = cb; + + return request; + } + public boolean isBitmapOnly() { return mIsBitmapOnly; } |