18af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein/* 28af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * Copyright (C) 2014 The Android Open Source Project 38af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * 48af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * Licensed under the Apache License, Version 2.0 (the "License"); 58af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * you may not use this file except in compliance with the License. 68af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * You may obtain a copy of the License at 78af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * 88af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * http://www.apache.org/licenses/LICENSE-2.0 98af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * 108af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * Unless required by applicable law or agreed to in writing, software 118af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * distributed under the License is distributed on an "AS IS" BASIS, 128af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * See the License for the specific language governing permissions and 148af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * limitations under the License. 158af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein */ 168af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein 178af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sappersteinpackage com.android.ex.chips; 188af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein 198af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein/** 208af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * Used by the {@link com.android.ex.chips.BaseRecipientAdapter} to handle fetching 218af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * photos from external sources and caching them for faster lookup later. 228af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein */ 238af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sappersteinpublic interface PhotoManager { 248af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein 258af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein /** The number of photos cached in this Adapter. */ 268af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein public static final int PHOTO_CACHE_SIZE = 20; 278af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein 288af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein /** 298af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * Sets the {@link com.android.ex.chips.RecipientEntry}'s photo bytes. If the photo bytes 308af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * are cached, this action happens immediately. Otherwise, the work to fetch the photo 318af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * bytes is performed asynchronously before setting the value on the UI thread.<p/> 328af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * 338af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * If the photo bytes were fetched asynchronously, 348af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * {@link PhotoManagerCallback#onPhotoBytesAsynchronouslyPopulated()} is called. This 358af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein * method is not called if the photo bytes have been cached previously (because no 3650429c51adbd79c5d7dd5beb2c267daf9465f20fAndrew Sapperstein * asynchronous work was performed). In that case, 3750429c51adbd79c5d7dd5beb2c267daf9465f20fAndrew Sapperstein * {@link PhotoManagerCallback#onPhotoBytesPopulated()} is called. 388af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein */ 398af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein void populatePhotoBytesAsync(RecipientEntry entry, PhotoManagerCallback callback); 408af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein 418af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein interface PhotoManagerCallback { 4250429c51adbd79c5d7dd5beb2c267daf9465f20fAndrew Sapperstein void onPhotoBytesPopulated(); 438af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein void onPhotoBytesAsynchronouslyPopulated(); 440efdc53cd0d040c1a27a7d39003916e54e284be2Jin Cao void onPhotoBytesAsyncLoadFailed(); 458af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein } 468af0d3b6f34e03c08c8e67be2190da01c59889daAndrew Sapperstein} 47