Andrew Sapperstein | 8af0d3b | 2014-05-02 15:23:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.ex.chips; |
| 18 | |
| 19 | /** |
| 20 | * Used by the {@link com.android.ex.chips.BaseRecipientAdapter} to handle fetching |
| 21 | * photos from external sources and caching them for faster lookup later. |
| 22 | */ |
| 23 | public interface PhotoManager { |
| 24 | |
| 25 | /** The number of photos cached in this Adapter. */ |
| 26 | public static final int PHOTO_CACHE_SIZE = 20; |
| 27 | |
| 28 | /** |
| 29 | * Sets the {@link com.android.ex.chips.RecipientEntry}'s photo bytes. If the photo bytes |
| 30 | * are cached, this action happens immediately. Otherwise, the work to fetch the photo |
| 31 | * bytes is performed asynchronously before setting the value on the UI thread.<p/> |
| 32 | * |
| 33 | * If the photo bytes were fetched asynchronously, |
| 34 | * {@link PhotoManagerCallback#onPhotoBytesAsynchronouslyPopulated()} is called. This |
| 35 | * method is not called if the photo bytes have been cached previously (because no |
Andrew Sapperstein | 50429c5 | 2014-06-12 15:12:10 -0700 | [diff] [blame] | 36 | * asynchronous work was performed). In that case, |
| 37 | * {@link PhotoManagerCallback#onPhotoBytesPopulated()} is called. |
Andrew Sapperstein | 8af0d3b | 2014-05-02 15:23:19 -0700 | [diff] [blame] | 38 | */ |
| 39 | void populatePhotoBytesAsync(RecipientEntry entry, PhotoManagerCallback callback); |
| 40 | |
Andrew Sapperstein | 8af0d3b | 2014-05-02 15:23:19 -0700 | [diff] [blame] | 41 | interface PhotoManagerCallback { |
Andrew Sapperstein | 50429c5 | 2014-06-12 15:12:10 -0700 | [diff] [blame] | 42 | void onPhotoBytesPopulated(); |
Andrew Sapperstein | 8af0d3b | 2014-05-02 15:23:19 -0700 | [diff] [blame] | 43 | void onPhotoBytesAsynchronouslyPopulated(); |
Jin Cao | 0efdc53 | 2014-06-04 15:35:16 -0700 | [diff] [blame] | 44 | void onPhotoBytesAsyncLoadFailed(); |
Andrew Sapperstein | 8af0d3b | 2014-05-02 15:23:19 -0700 | [diff] [blame] | 45 | } |
| 46 | } |