// Path: src/com/android/volley/toolbox/ImageLoader.java
// public class ImageContainer {
//     /**
//      * The most relevant bitmap for the container. If the image was in cache, the
//      * Holder to use for the final bitmap (the one that pairs to the requested URL).
//      */
//     private Bitmap mBitmap;
// 
//     private final ImageListener mListener;
// 
//     /** The cache key that was associated with the request */
//     private final String mCacheKey;
// 
//     /** The request URL that was specified */
//     private final String mRequestUrl;
// 
//     /**
//      * Constructs a BitmapContainer object.
//      * @param bitmap The final bitmap (if it exists).
//      * @param requestUrl The requested URL for this container.
//      * @param cacheKey The cache key that identifies the requested URL for this container.
//      */
//     public ImageContainer(Bitmap bitmap, String requestUrl,
//             String cacheKey, ImageListener listener) {
//         mBitmap = bitmap;
//         mRequestUrl = requestUrl;
//         mCacheKey = cacheKey;
//         mListener = listener;
//     }
// 
//     /**
//      * Releases interest in the in-flight request (and cancels it if no one else is listening).
//      */
//     public void cancelRequest() {
//         if (mListener == null) {
//             return;
//         }
// 
//         BatchedImageRequest request = mInFlightRequests.get(mCacheKey);
//         if (request != null) {
//             boolean canceled = request.removeContainerAndCancelIfNecessary(this);
//             if (canceled) {
//                 mInFlightRequests.remove(mCacheKey);
//             }
//         } else {
//             // check to see if it is already batched for delivery.
//             request = mBatchedResponses.get(mCacheKey);
//             if (request != null) {
//                 request.removeContainerAndCancelIfNecessary(this);
//                 if (request.mContainers.size() == 0) {
//                     mBatchedResponses.remove(mCacheKey);
//                 }
//             }
//         }
//     }
// 
//     /**
//      * Returns the bitmap associated with the request URL if it has been loaded, null otherwise.
//      */
//     public Bitmap getBitmap() {
//         return mBitmap;
//     }
// 
//     /**
//      * Returns the requested URL for this container.
//      */
//     public String getRequestUrl() {
//         return mRequestUrl;
//     }
// }
// 
// Path: src/com/android/volley/toolbox/ImageLoader.java
// public interface ImageListener extends ErrorListener {
//     /**
//      * Listens for non-error changes to the loading of the image request.
//      *
//      * @param response Holds all information pertaining to the request, as well
//      * as the bitmap (if it is loaded).
//      * @param isImmediate True if this was called during ImageLoader.get() variants.
//      * This can be used to differentiate between a cached image loading and a network
//      * image loading in order to, for example, run an animation to fade in network loaded
//      * images.
//      */
//     public void onResponse(ImageContainer response, boolean isImmediate);
// }


import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageLoader.ImageContainer;
import com.android.volley.toolbox.ImageLoader.ImageListener;
/**
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.volley.toolbox;



/**
 * Handles fetching an image from a URL as well as the life-cycle of the
 * associated request.
 */
public class NetworkImageView extends ImageView {
    /** The URL of the network image to load */
    private String mUrl;

    /**
     * Resource ID of the image to be used as a placeholder until the network image is loaded.
     */
    private int mDefaultImageId;

    /**
     * Resource ID of the image to be used if the network response fails.
     */
    private int mErrorImageId;

    /** Local copy of the ImageLoader. */
    private ImageLoader mImageLoader;

    /** Current ImageContainer. (either in-flight or finished) */
// Path: src/com/android/volley/toolbox/ImageLoader.java
// public class ImageContainer {
//     /**
//      * The most relevant bitmap for the container. If the image was in cache, the
//      * Holder to use for the final bitmap (the one that pairs to the requested URL).
//      */
//     private Bitmap mBitmap;
// 
//     private final ImageListener mListener;
// 
//     /** The cache key that was associated with the request */
//     private final String mCacheKey;
// 
//     /** The request URL that was specified */
//     private final String mRequestUrl;
// 
//     /**
//      * Constructs a BitmapContainer object.
//      * @param bitmap The final bitmap (if it exists).
//      * @param requestUrl The requested URL for this container.
//      * @param cacheKey The cache key that identifies the requested URL for this container.
//      */
//     public ImageContainer(Bitmap bitmap, String requestUrl,
//             String cacheKey, ImageListener listener) {
//         mBitmap = bitmap;
//         mRequestUrl = requestUrl;
//         mCacheKey = cacheKey;
//         mListener = listener;
//     }
// 
//     /**
//      * Releases interest in the in-flight request (and cancels it if no one else is listening).
//      */
//     public void cancelRequest() {
//         if (mListener == null) {
//             return;
//         }
// 
//         BatchedImageRequest request = mInFlightRequests.get(mCacheKey);
//         if (request != null) {
//             boolean canceled = request.removeContainerAndCancelIfNecessary(this);
//             if (canceled) {
//                 mInFlightRequests.remove(mCacheKey);
//             }
//         } else {
//             // check to see if it is already batched for delivery.
//             request = mBatchedResponses.get(mCacheKey);
//             if (request != null) {
//                 request.removeContainerAndCancelIfNecessary(this);
//                 if (request.mContainers.size() == 0) {
//                     mBatchedResponses.remove(mCacheKey);
//                 }
//             }
//         }
//     }
// 
//     /**
//      * Returns the bitmap associated with the request URL if it has been loaded, null otherwise.
//      */
//     public Bitmap getBitmap() {
//         return mBitmap;
//     }
// 
//     /**
//      * Returns the requested URL for this container.
//      */
//     public String getRequestUrl() {
//         return mRequestUrl;
//     }
// }
// 
// Path: src/com/android/volley/toolbox/ImageLoader.java
// public interface ImageListener extends ErrorListener {
//     /**
//      * Listens for non-error changes to the loading of the image request.
//      *
//      * @param response Holds all information pertaining to the request, as well
//      * as the bitmap (if it is loaded).
//      * @param isImmediate True if this was called during ImageLoader.get() variants.
//      * This can be used to differentiate between a cached image loading and a network
//      * image loading in order to, for example, run an animation to fade in network loaded
//      * images.
//      */
//     public void onResponse(ImageContainer response, boolean isImmediate);
// }


// Path: src/com/android/volley/toolbox/NetworkImageView.java
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageLoader.ImageContainer;
import com.android.volley.toolbox.ImageLoader.ImageListener;

/**
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.volley.toolbox;



/**
 * Handles fetching an image from a URL as well as the life-cycle of the
 * associated request.
 */
public class NetworkImageView extends ImageView {
    /** The URL of the network image to load */
    private String mUrl;

    /**
     * Resource ID of the image to be used as a placeholder until the network image is loaded.
     */
    private int mDefaultImageId;

    /**
     * Resource ID of the image to be used if the network response fails.
     */
    private int mErrorImageId;

    /** Local copy of the ImageLoader. */
    private ImageLoader mImageLoader;

    /** Current ImageContainer. (either in-flight or finished) */
    private ImageContainer mImageContainer;