// Path: app/src/main/java/com/choices/imagecompare/configs/ConfigConstants.java
// public class ConfigConstants {
//     public static final int MAX_DISK_CACHE_SIZE = 40 * ByteConstants.MB;
//     private static final int MAX_HEAP_SIZE = (int) Runtime.getRuntime().maxMemory();
//     public static final int MAX_MEMORY_CACHE_SIZE = MAX_HEAP_SIZE / 4;
// }


import android.content.Context;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.BasicNetwork;
import com.android.volley.toolbox.DiskBasedCache;
import com.android.volley.toolbox.HurlStack;
import com.android.volley.toolbox.ImageLoader;
import com.choices.imagecompare.configs.ConfigConstants;
import java.io.File;
/*
 * This file provided by Facebook is for non-commercial testing and evaluation
 * purposes only.  Facebook reserves all rights not expressly granted.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.choices.imagecompare.configs.volley;




/**
 * Creates singletons of relevant volley classes
 */
public class SampleVolleyFactory {
    private static final String VOLLEY_CACHE_DIR = "volley";

    private static ImageLoader sImageLoader;
    private static RequestQueue sRequestQueue;
    private static VolleyMemoryCache sMemoryCache;

    public static RequestQueue getRequestQueue(Context context) {
        if (sRequestQueue == null) {
            File cacheDir = new File(context.getCacheDir(), VOLLEY_CACHE_DIR);
            sRequestQueue = new RequestQueue(
                    new DiskBasedCache(cacheDir, ConfigConstants.MAX_DISK_CACHE_SIZE),
                    new BasicNetwork(new HurlStack()));
            sRequestQueue.start();
        }
        return sRequestQueue;
    }


    public static VolleyMemoryCache getMemoryCache() {
        if (sMemoryCache == null) {
// Path: app/src/main/java/com/choices/imagecompare/configs/ConfigConstants.java
// public class ConfigConstants {
//     public static final int MAX_DISK_CACHE_SIZE = 40 * ByteConstants.MB;
//     private static final int MAX_HEAP_SIZE = (int) Runtime.getRuntime().maxMemory();
//     public static final int MAX_MEMORY_CACHE_SIZE = MAX_HEAP_SIZE / 4;
// }


// Path: app/src/main/java/com/choices/imagecompare/configs/volley/SampleVolleyFactory.java
import android.content.Context;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.BasicNetwork;
import com.android.volley.toolbox.DiskBasedCache;
import com.android.volley.toolbox.HurlStack;
import com.android.volley.toolbox.ImageLoader;
import com.choices.imagecompare.configs.ConfigConstants;
import java.io.File;

/*
 * This file provided by Facebook is for non-commercial testing and evaluation
 * purposes only.  Facebook reserves all rights not expressly granted.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.choices.imagecompare.configs.volley;




/**
 * Creates singletons of relevant volley classes
 */
public class SampleVolleyFactory {
    private static final String VOLLEY_CACHE_DIR = "volley";

    private static ImageLoader sImageLoader;
    private static RequestQueue sRequestQueue;
    private static VolleyMemoryCache sMemoryCache;

    public static RequestQueue getRequestQueue(Context context) {
        if (sRequestQueue == null) {
            File cacheDir = new File(context.getCacheDir(), VOLLEY_CACHE_DIR);
            sRequestQueue = new RequestQueue(
                    new DiskBasedCache(cacheDir, ConfigConstants.MAX_DISK_CACHE_SIZE),
                    new BasicNetwork(new HurlStack()));
            sRequestQueue.start();
        }
        return sRequestQueue;
    }


    public static VolleyMemoryCache getMemoryCache() {
        if (sMemoryCache == null) {
            sMemoryCache = new VolleyMemoryCache(ConfigConstants.MAX_MEMORY_CACHE_SIZE);