// Path: library/src/main/java/com/siu/android/volleyball/toolbox/BallImageLoader.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: library/src/main/java/com/siu/android/volleyball/toolbox/BallImageLoader.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.siu.android.volleyball.toolbox.BallImageLoader.ImageContainer;
import com.siu.android.volleyball.toolbox.BallImageLoader.ImageListener;
            if (mImageContainer.getRequestUrl().equals(mUrl)) {
                // if the request is from the same URL, return.
                return;
            } else {
                // if there is a pre-existing request, cancel it if it's fetching a different URL.
                mImageContainer.cancelRequest();
                setImageBitmap(null);
            }
        }

        // The pre-existing content of this view didn't match the current URL. Load the new image
        // from the network.
        ImageContainer newContainer = mImageLoader.get(mUrl,
                new ImageListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        if (mErrorImageId != 0) {
                            setImageResource(mErrorImageId);
                        }
                    }

                    @Override
                    public void onResponse(final ImageContainer response, boolean isImmediate) {
                        // If this was an immediate response that was delivered inside of a layout
                        // pass do not set the image immediately as it will trigger a requestLayout
                        // inside of a layout. Instead, defer setting the image by posting back to
                        // the main thread.
                        if (isImmediate && isInLayoutPass) {
                            post(new Runnable() {
                                @Override
// Path: library/src/main/java/com/siu/android/volleyball/toolbox/BallImageLoader.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: library/src/main/java/com/siu/android/volleyball/toolbox/BallImageLoader.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: library/src/main/java/com/siu/android/volleyball/toolbox/BallNetworkImageView.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.siu.android.volleyball.toolbox.BallImageLoader.ImageContainer;
import com.siu.android.volleyball.toolbox.BallImageLoader.ImageListener;

            if (mImageContainer.getRequestUrl().equals(mUrl)) {
                // if the request is from the same URL, return.
                return;
            } else {
                // if there is a pre-existing request, cancel it if it's fetching a different URL.
                mImageContainer.cancelRequest();
                setImageBitmap(null);
            }
        }

        // The pre-existing content of this view didn't match the current URL. Load the new image
        // from the network.
        ImageContainer newContainer = mImageLoader.get(mUrl,
                new ImageListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        if (mErrorImageId != 0) {
                            setImageResource(mErrorImageId);
                        }
                    }

                    @Override
                    public void onResponse(final ImageContainer response, boolean isImmediate) {
                        // If this was an immediate response that was delivered inside of a layout
                        // pass do not set the image immediately as it will trigger a requestLayout
                        // inside of a layout. Instead, defer setting the image by posting back to
                        // the main thread.
                        if (isImmediate && isInLayoutPass) {
                            post(new Runnable() {
                                @Override
                                public void run() {