blob: 66a64c29e098dbb566dadb75615c54f60ef188fb [file] [log] [blame]
Andrew Sapperstein8af0d3b2014-05-02 15:23:19 -07001/*
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
17package 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 */
23public 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 Sapperstein50429c52014-06-12 15:12:10 -070036 * asynchronous work was performed). In that case,
37 * {@link PhotoManagerCallback#onPhotoBytesPopulated()} is called.
Andrew Sapperstein8af0d3b2014-05-02 15:23:19 -070038 */
39 void populatePhotoBytesAsync(RecipientEntry entry, PhotoManagerCallback callback);
40
Andrew Sapperstein8af0d3b2014-05-02 15:23:19 -070041 interface PhotoManagerCallback {
Andrew Sapperstein50429c52014-06-12 15:12:10 -070042 void onPhotoBytesPopulated();
Andrew Sapperstein8af0d3b2014-05-02 15:23:19 -070043 void onPhotoBytesAsynchronouslyPopulated();
Jin Cao0efdc532014-06-04 15:35:16 -070044 void onPhotoBytesAsyncLoadFailed();
Andrew Sapperstein8af0d3b2014-05-02 15:23:19 -070045 }
46}