package ch.pizzalemon.android.helper;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import ch.pizzalemon.android.activity.BaseActivity;

public class NetworkHelper {

    public static boolean isNetworkAvailable(){

        ConnectivityManager connectivityManager = (ConnectivityManager) BaseActivity.currentActivity.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();

        if (activeNetworkInfo == null)
            return false;

        else if (!activeNetworkInfo.isConnected())
            return false;

        else if (!activeNetworkInfo.isAvailable())
            return false;

        return true;
    }

}
