// Path: app/src/main/java/com/pasta/mensadd/networking/callbacks/AbstractCallback.java
// public interface AbstractCallback {
//     void onResponseMessage(int responseType, String message);
// }
// 
// Path: app/src/main/java/com/pasta/mensadd/networking/callbacks/LoadCanteensCallback.java
// public interface LoadCanteensCallback extends AbstractCallback{}
// 
// Path: app/src/main/java/com/pasta/mensadd/networking/callbacks/LoadImageCallback.java
// public interface LoadImageCallback {
//     void onResponseMessage(int responseType, String message, Bitmap bitmap);
// }
// 
// Path: app/src/main/java/com/pasta/mensadd/networking/callbacks/LoadNewsCallback.java
// public interface LoadNewsCallback extends AbstractCallback{}


import android.content.Context;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.util.Log;
import android.widget.Toast;
import com.android.volley.Cache;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.BasicNetwork;
import com.android.volley.toolbox.DiskBasedCache;
import com.android.volley.toolbox.HurlStack;
import com.android.volley.toolbox.ImageRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import com.pasta.mensadd.R;
import com.pasta.mensadd.networking.callbacks.AbstractCallback;
import com.pasta.mensadd.networking.callbacks.LoadCanteensCallback;
import com.pasta.mensadd.networking.callbacks.LoadImageCallback;
import com.pasta.mensadd.networking.callbacks.LoadNewsCallback;
import org.json.JSONException;
import org.json.JSONObject;
                    }
                });
        mRequestQueue.add(request);
    }

    public void doImageRequest(String url, final LoadImageCallback callback) {
        Log.i("IMAGE", url);
        ImageRequest request = new ImageRequest(url, new Response.Listener<Bitmap>() {
            @Override
            public void onResponse(Bitmap response) {
                callback.onResponseMessage(SUCCESS, "", response);
            }
        }, 0, 0, null, Bitmap.Config.ARGB_8888, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                callback.onResponseMessage(ERROR,"",null);
            }
        });
        request.setRetryPolicy(new DefaultRetryPolicy(2000, 0, 1.0f));
        mRequestQueue.add(request);
    }

    public static boolean isConnectedToInternet(Context context) {
        boolean connected;
        try {
            ConnectivityManager conMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);

            connected = (   conMgr.getActiveNetworkInfo() != null &&
                    conMgr.getActiveNetworkInfo().isAvailable() &&
                    conMgr.getActiveNetworkInfo().isConnected()   );
// Path: app/src/main/java/com/pasta/mensadd/networking/callbacks/AbstractCallback.java
// public interface AbstractCallback {
//     void onResponseMessage(int responseType, String message);
// }
// 
// Path: app/src/main/java/com/pasta/mensadd/networking/callbacks/LoadCanteensCallback.java
// public interface LoadCanteensCallback extends AbstractCallback{}
// 
// Path: app/src/main/java/com/pasta/mensadd/networking/callbacks/LoadImageCallback.java
// public interface LoadImageCallback {
//     void onResponseMessage(int responseType, String message, Bitmap bitmap);
// }
// 
// Path: app/src/main/java/com/pasta/mensadd/networking/callbacks/LoadNewsCallback.java
// public interface LoadNewsCallback extends AbstractCallback{}


// Path: app/src/main/java/com/pasta/mensadd/networking/NetworkController.java
import android.content.Context;
import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.util.Log;
import android.widget.Toast;
import com.android.volley.Cache;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.BasicNetwork;
import com.android.volley.toolbox.DiskBasedCache;
import com.android.volley.toolbox.HurlStack;
import com.android.volley.toolbox.ImageRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import com.pasta.mensadd.R;
import com.pasta.mensadd.networking.callbacks.AbstractCallback;
import com.pasta.mensadd.networking.callbacks.LoadCanteensCallback;
import com.pasta.mensadd.networking.callbacks.LoadImageCallback;
import com.pasta.mensadd.networking.callbacks.LoadNewsCallback;
import org.json.JSONException;
import org.json.JSONObject;

                    }
                });
        mRequestQueue.add(request);
    }

    public void doImageRequest(String url, final LoadImageCallback callback) {
        Log.i("IMAGE", url);
        ImageRequest request = new ImageRequest(url, new Response.Listener<Bitmap>() {
            @Override
            public void onResponse(Bitmap response) {
                callback.onResponseMessage(SUCCESS, "", response);
            }
        }, 0, 0, null, Bitmap.Config.ARGB_8888, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                callback.onResponseMessage(ERROR,"",null);
            }
        });
        request.setRetryPolicy(new DefaultRetryPolicy(2000, 0, 1.0f));
        mRequestQueue.add(request);
    }

    public static boolean isConnectedToInternet(Context context) {
        boolean connected;
        try {
            ConnectivityManager conMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);

            connected = (   conMgr.getActiveNetworkInfo() != null &&
                    conMgr.getActiveNetworkInfo().isAvailable() &&
                    conMgr.getActiveNetworkInfo().isConnected()   );
        } catch (Exception e) {