Home | History | Annotate | Download | only in chips
      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
     36      * asynchronous work was performed). In that case,
     37      * {@link PhotoManagerCallback#onPhotoBytesPopulated()} is called.
     38      */
     39     void populatePhotoBytesAsync(RecipientEntry entry, PhotoManagerCallback callback);
     40 
     41     interface PhotoManagerCallback {
     42         void onPhotoBytesPopulated();
     43         void onPhotoBytesAsynchronouslyPopulated();
     44         void onPhotoBytesAsyncLoadFailed();
     45     }
     46 }
     47