package myapplication.myvolleyapp.api;

import android.content.Context;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;

/**
 * Created by david on 11/22/16.
 */

public class ApiClient {


    private static ApiClient sInstance;
    private RequestQueue mRequestQueue;
    private ImageLoader mImageLoader;
    private static Context mContext;

    private ApiClient(Context context) {
        mContext = context;
        mRequestQueue = getRequestQueue();
        mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache());
    }


    public static ApiClient getInstance(Context context) {
        if (sInstance == null) {
            sInstance = new ApiClient(context);
        }
        return sInstance;
    }


    public RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            // getApplicationContext() is key, it keeps you from leaking the
            // Activity or BroadcastReceiver if someone passes one in.
            mRequestQueue = Volley.newRequestQueue(mContext.getApplicationContext());
        }
        return mRequestQueue;
    }

    public <T> void addToRequestQueue(Request<T> req) {
        getRequestQueue().add(req);
    }

    public ImageLoader getImageLoader() {
        return mImageLoader;
    }


}

@@ -96,55 +96,266 @@
 ley.
-Request;%0Aimport com.android.volley.RequestQueue
+Cache;%0Aimport com.android.volley.Network;%0Aimport com.android.volley.Request;%0Aimport com.android.volley.RequestQueue;%0Aimport com.android.volley.toolbox.BasicNetwork;%0Aimport com.android.volley.toolbox.DiskBasedCache;%0Aimport com.android.volley.toolbox.HurlStack
 ;%0Aim
@@ -402,50 +402,8 @@
 der;
-%0Aimport com.android.volley.toolbox.Volley;
 %0A%0A/*
@@ -1079,32 +1079,509 @@
 ueue == null) %7B%0A
+%0A            // Instantiate the cache%0A            Cache cache = new DiskBasedCache(mContext.getCacheDir(), 1024 * 1024); // 1MB cap%0A            // Set up the network to use HttpURLConnection as the HTTP client.%0A            Network network = new BasicNetwork(new HurlStack());%0A            // Instantiate the RequestQueue with the cache and network.%0A            mRequestQueue = new RequestQueue(cache, network);%0A            // Start the queue%0A            mRequestQueue.start();%0A%0A
             // g
@@ -1716,32 +1716,34 @@
 in.%0A            
+//
 mRequestQueue = 

add volley cache