package com.dahamit.dahammall.util;

import android.content.Context;
import android.net.ConnectivityManager;

/**
 * Created by macbookpro on 2018. 10. 20..
 */

public class Util {
    public static Boolean isNetWork(Context ctx){
        ConnectivityManager manager = (ConnectivityManager) ctx.getSystemService (ctx.CONNECTIVITY_SERVICE);
        boolean isMobileAvailable = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isAvailable();
        boolean isMobileConnect = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting();
        boolean isWifiAvailable = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isAvailable();
        boolean isWifiConnect = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();

        if ((isWifiAvailable && isWifiConnect) || (isMobileAvailable && isMobileConnect)){
            return true;
        }else{
            return false;
        }
    }
}
