package com.kevoroid.andhackernews;

import android.content.Context;

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

/**
 * Created by kevin on 5/30/17.
 */

public class AndHackerNewsController {

    private static AndHackerNewsController mInstance;
    private static Context mContext;
    private RequestQueue mRequestQueue;

    private AndHackerNewsController(Context context) {
        mContext = context;
        initVolley();
    }

    public static synchronized AndHackerNewsController getInstance(Context context) {
        if (mInstance == null) {
            mInstance = new AndHackerNewsController(context);
        }
        return mInstance;
    }

    private void initVolley() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(mContext.getApplicationContext());
        }
    }

    public RequestQueue getRequestQueue() {
        return mRequestQueue;
    }

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

@@ -320,45 +320,8 @@
 ce;%0A
-    private static Context mContext;%0A
     
@@ -416,36 +416,8 @@
 ) %7B%0A
-        mContext = context;%0A
     
@@ -431,16 +431,23 @@
 tVolley(
+context
 );%0A    %7D
@@ -622,24 +622,48 @@
 ller(context
+.getApplicationContext()
 );%0A        %7D
@@ -724,16 +724,31 @@
 tVolley(
+Context context
 ) %7B%0A    
@@ -835,10 +835,9 @@
 eue(
-mC
+c
 onte

fix memory leak of controller