1037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan/* 2037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Copyright (C) 2008 The Android Open Source Project 3037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * 4037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Licensed under the Apache License, Version 2.0 (the "License"); 5037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * you may not use this file except in compliance with the License. 6037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * You may obtain a copy of the License at 7037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * 8037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * http://www.apache.org/licenses/LICENSE-2.0 9037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * 10037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Unless required by applicable law or agreed to in writing, software 11037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * distributed under the License is distributed on an "AS IS" BASIS, 12037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * See the License for the specific language governing permissions and 14037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * limitations under the License. 15037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan */ 16037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 17037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanpackage com.android.calendar; 18037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 19d845fbe558d5229102b58cce70a1b29fe6cb6967Erikimport com.android.calendar.event.EditEventHelper.AttendeeItem; 20d845fbe558d5229102b58cce70a1b29fe6cb6967Erik 21037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.content.Context; 22037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.graphics.drawable.Drawable; 23037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.net.Uri; 24037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.os.Handler; 25037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.os.HandlerThread; 26037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.os.Looper; 27037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.os.Message; 28037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.provider.ContactsContract.Contacts; 29037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.util.Log; 30037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.view.View; 31037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport android.widget.ImageView; 32037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 33037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanimport java.io.InputStream; 34037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 35037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan/** 36037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Helper class for async access of images. 37037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan */ 38037c06963c0b5c96c6464169e5612f51b290fe46Michael Chanpublic class ContactsAsyncHelper extends Handler { 39037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 40037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan private static final boolean DBG = false; 41037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan private static final String LOG_TAG = "ContactsAsyncHelper"; 42037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 43a7694eead7cbb293990bc89c3906e17bad36194cErik private static ContactsAsyncHelper mInstance = null; 44a7694eead7cbb293990bc89c3906e17bad36194cErik 45037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan /** 46037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Interface for a WorkerHandler result return. 47037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan */ 48037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public interface OnImageLoadCompleteListener { 49037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan /** 50037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Called when the image load is complete. 51037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * 52037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * @param imagePresent true if an image was found 53037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan */ 54037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public void onImageLoadComplete(int token, Object cookie, ImageView iView, 55037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan boolean imagePresent); 56037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 57037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 58037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // constants 59037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan private static final int EVENT_LOAD_IMAGE = 1; 60d845fbe558d5229102b58cce70a1b29fe6cb6967Erik private static final int EVENT_LOAD_DRAWABLE = 2; 61037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan private static final int DEFAULT_TOKEN = -1; 62037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 63037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // static objects 64037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan private static Handler sThreadHandler; 65037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 66037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan private static final class WorkerArgs { 67037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public Context context; 68037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public ImageView view; 69037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public Uri uri; 70037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public int defaultResource; 71037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public Object result; 72d845fbe558d5229102b58cce70a1b29fe6cb6967Erik public AttendeeItem item; 73d845fbe558d5229102b58cce70a1b29fe6cb6967Erik public Runnable callback; 74037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 75037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 76037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan /** 77037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Thread worker class that handles the task of opening the stream and loading 78037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * the images. 79037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan */ 80037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan private class WorkerHandler extends Handler { 81037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public WorkerHandler(Looper looper) { 82037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan super(looper); 83037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 84037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 85037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan @Override 86037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public void handleMessage(Message msg) { 87037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan WorkerArgs args = (WorkerArgs) msg.obj; 88037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 89037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan switch (msg.arg1) { 90d845fbe558d5229102b58cce70a1b29fe6cb6967Erik case EVENT_LOAD_DRAWABLE: 91037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan case EVENT_LOAD_IMAGE: 92037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan InputStream inputStream = null; 93037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan try { 94037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan inputStream = Contacts.openContactPhotoInputStream( 95037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.context.getContentResolver(), args.uri); 96037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } catch (Exception e) { 97037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan Log.e(LOG_TAG, "Error opening photo input stream", e); 98037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 99037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 100037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan if (inputStream != null) { 101037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.result = Drawable.createFromStream(inputStream, args.uri.toString()); 102037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 103037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan if (DBG) Log.d(LOG_TAG, "Loading image: " + msg.arg1 + 104037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan " token: " + msg.what + " image URI: " + args.uri); 105037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } else { 106037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.result = null; 107037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan if (DBG) Log.d(LOG_TAG, "Problem with image: " + msg.arg1 + 108037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan " token: " + msg.what + " image URI: " + args.uri + 109037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan ", using default image."); 110037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 111037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan break; 112037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan default: 113037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 114037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 115037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // send the reply to the enclosing class. 116037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan Message reply = ContactsAsyncHelper.this.obtainMessage(msg.what); 117037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan reply.arg1 = msg.arg1; 118037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan reply.obj = msg.obj; 119037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan reply.sendToTarget(); 120037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 121037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 122037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 123037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan /** 124037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Private constructor for static class 125037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan */ 126037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan private ContactsAsyncHelper() { 127037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan HandlerThread thread = new HandlerThread("ContactsAsyncWorker"); 128037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan thread.start(); 129037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan sThreadHandler = new WorkerHandler(thread.getLooper()); 130037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 131037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 132037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan /** 133037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Start an image load, attach the result to the specified CallerInfo object. 134037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Note, when the query is started, we make the ImageView INVISIBLE if the 135037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * placeholderImageResource value is -1. When we're given a valid (!= -1) 136037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * placeholderImageResource value, we make sure the image is visible. 137037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan */ 138037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public static final void updateImageViewWithContactPhotoAsync(Context context, 1398fa3111ceaab2b26a322caa873f352bb4eb3e783Daniel Lehmann ImageView imageView, Uri contact, int placeholderImageResource) { 140037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 141037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // in case the source caller info is null, the URI will be null as well. 142037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // just update using the placeholder image in this case. 1438fa3111ceaab2b26a322caa873f352bb4eb3e783Daniel Lehmann if (contact == null) { 144037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan if (DBG) Log.d(LOG_TAG, "target image is null, just display placeholder."); 145037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan imageView.setVisibility(View.VISIBLE); 146037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan imageView.setImageResource(placeholderImageResource); 147037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan return; 148037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 149037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 150037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // Added additional Cookie field in the callee to handle arguments 151037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // sent to the callback function. 152037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 153037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // setup arguments 154037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan WorkerArgs args = new WorkerArgs(); 155037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.context = context; 156037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.view = imageView; 1578fa3111ceaab2b26a322caa873f352bb4eb3e783Daniel Lehmann args.uri = contact; 158037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.defaultResource = placeholderImageResource; 159037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 160a7694eead7cbb293990bc89c3906e17bad36194cErik if (mInstance == null) { 161a7694eead7cbb293990bc89c3906e17bad36194cErik mInstance = new ContactsAsyncHelper(); 162a7694eead7cbb293990bc89c3906e17bad36194cErik } 163037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // setup message arguments 164037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan Message msg = sThreadHandler.obtainMessage(DEFAULT_TOKEN); 165037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan msg.arg1 = EVENT_LOAD_IMAGE; 166037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan msg.obj = args; 167037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 168037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan if (DBG) Log.d(LOG_TAG, "Begin loading image: " + args.uri + 169037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan ", displaying default image for now."); 170037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 171037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // set the default image first, when the query is complete, we will 172037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // replace the image with the correct one. 173037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan if (placeholderImageResource != -1) { 174037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan imageView.setVisibility(View.VISIBLE); 175037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan imageView.setImageResource(placeholderImageResource); 176037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } else { 177037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan imageView.setVisibility(View.INVISIBLE); 178037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 179037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 180037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // notify the thread to begin working 181037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan sThreadHandler.sendMessage(msg); 182037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 183037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan 184037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan /** 185d845fbe558d5229102b58cce70a1b29fe6cb6967Erik * Start an image load, attach the result to the specified CallerInfo object. 186d845fbe558d5229102b58cce70a1b29fe6cb6967Erik * Note, when the query is started, we make the ImageView INVISIBLE if the 187d845fbe558d5229102b58cce70a1b29fe6cb6967Erik * placeholderImageResource value is -1. When we're given a valid (!= -1) 188d845fbe558d5229102b58cce70a1b29fe6cb6967Erik * placeholderImageResource value, we make sure the image is visible. 189d845fbe558d5229102b58cce70a1b29fe6cb6967Erik */ 190d845fbe558d5229102b58cce70a1b29fe6cb6967Erik public static final void retrieveContactPhotoAsync(Context context, 1918fa3111ceaab2b26a322caa873f352bb4eb3e783Daniel Lehmann AttendeeItem item, Runnable run, Uri photoUri) { 192d845fbe558d5229102b58cce70a1b29fe6cb6967Erik 193d845fbe558d5229102b58cce70a1b29fe6cb6967Erik // in case the source caller info is null, the URI will be null as well. 194d845fbe558d5229102b58cce70a1b29fe6cb6967Erik // just return as there's nothing to do. 1958fa3111ceaab2b26a322caa873f352bb4eb3e783Daniel Lehmann if (photoUri == null) { 196d845fbe558d5229102b58cce70a1b29fe6cb6967Erik return; 197d845fbe558d5229102b58cce70a1b29fe6cb6967Erik } 198d845fbe558d5229102b58cce70a1b29fe6cb6967Erik 199d845fbe558d5229102b58cce70a1b29fe6cb6967Erik // Added additional Cookie field in the callee to handle arguments 200d845fbe558d5229102b58cce70a1b29fe6cb6967Erik // sent to the callback function. 201d845fbe558d5229102b58cce70a1b29fe6cb6967Erik 202d845fbe558d5229102b58cce70a1b29fe6cb6967Erik // setup arguments 203d845fbe558d5229102b58cce70a1b29fe6cb6967Erik WorkerArgs args = new WorkerArgs(); 204d845fbe558d5229102b58cce70a1b29fe6cb6967Erik args.context = context; 205d845fbe558d5229102b58cce70a1b29fe6cb6967Erik args.item = item; 2068fa3111ceaab2b26a322caa873f352bb4eb3e783Daniel Lehmann args.uri = photoUri; 207d845fbe558d5229102b58cce70a1b29fe6cb6967Erik args.callback = run; 208d845fbe558d5229102b58cce70a1b29fe6cb6967Erik 209a7694eead7cbb293990bc89c3906e17bad36194cErik if (mInstance == null) { 210a7694eead7cbb293990bc89c3906e17bad36194cErik mInstance = new ContactsAsyncHelper(); 211a7694eead7cbb293990bc89c3906e17bad36194cErik } 212d845fbe558d5229102b58cce70a1b29fe6cb6967Erik // setup message arguments 213d845fbe558d5229102b58cce70a1b29fe6cb6967Erik Message msg = sThreadHandler.obtainMessage(DEFAULT_TOKEN); 214d845fbe558d5229102b58cce70a1b29fe6cb6967Erik msg.arg1 = EVENT_LOAD_DRAWABLE; 215d845fbe558d5229102b58cce70a1b29fe6cb6967Erik msg.obj = args; 216d845fbe558d5229102b58cce70a1b29fe6cb6967Erik 217d845fbe558d5229102b58cce70a1b29fe6cb6967Erik if (DBG) Log.d(LOG_TAG, "Begin loading drawable: " + args.uri); 218d845fbe558d5229102b58cce70a1b29fe6cb6967Erik 219d845fbe558d5229102b58cce70a1b29fe6cb6967Erik 220d845fbe558d5229102b58cce70a1b29fe6cb6967Erik // notify the thread to begin working 221d845fbe558d5229102b58cce70a1b29fe6cb6967Erik sThreadHandler.sendMessage(msg); 222d845fbe558d5229102b58cce70a1b29fe6cb6967Erik } 223d845fbe558d5229102b58cce70a1b29fe6cb6967Erik 224d845fbe558d5229102b58cce70a1b29fe6cb6967Erik /** 225037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan * Called when loading is done. 226037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan */ 227037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan @Override 228037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan public void handleMessage(Message msg) { 229037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan WorkerArgs args = (WorkerArgs) msg.obj; 230037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan switch (msg.arg1) { 231037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan case EVENT_LOAD_IMAGE: 232037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // if the image has been loaded then display it, otherwise set default. 233037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan // in either case, make sure the image is visible. 234037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan if (args.result != null) { 235037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.view.setVisibility(View.VISIBLE); 236037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.view.setImageDrawable((Drawable) args.result); 237037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } else if (args.defaultResource != -1) { 238037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.view.setVisibility(View.VISIBLE); 239037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan args.view.setImageResource(args.defaultResource); 240037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 241037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan break; 242d845fbe558d5229102b58cce70a1b29fe6cb6967Erik case EVENT_LOAD_DRAWABLE: 243d845fbe558d5229102b58cce70a1b29fe6cb6967Erik if (args.result != null) { 244d845fbe558d5229102b58cce70a1b29fe6cb6967Erik args.item.mBadge = (Drawable) args.result; 245d845fbe558d5229102b58cce70a1b29fe6cb6967Erik if (args.callback != null) { 246d845fbe558d5229102b58cce70a1b29fe6cb6967Erik args.callback.run(); 247d845fbe558d5229102b58cce70a1b29fe6cb6967Erik } 248d845fbe558d5229102b58cce70a1b29fe6cb6967Erik } 249d845fbe558d5229102b58cce70a1b29fe6cb6967Erik break; 250037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan default: 251037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 252037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan } 253037c06963c0b5c96c6464169e5612f51b290fe46Michael Chan} 254