package me.ykrank.s1next.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.os.Build;

public final class NetworkUtil {

    private NetworkUtil() {
    }

    /**
     * Checks whether the Wi-Fi network connectivity exists and whether it is possible to
     * establish connections and pass data.
     *
     * @return {@code true} if the Wi-FI network connectivity exists, {@code false} otherwise.
     */
    @SuppressWarnings("deprecation")
    public static boolean isWifiConnected(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Network[] networks = connectivityManager.getAllNetworks();
            if (networks != null) {
                for (Network network : networks) {
                    NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
                    if (networkInfo != null &&
                            networkInfo.getType() == ConnectivityManager.TYPE_WIFI
                            && networkInfo.isConnected()) {
                        return true;
                    }
                }
            }
        } else {
            NetworkInfo networkInfo = connectivityManager.getNetworkInfo(
                    ConnectivityManager.TYPE_WIFI);
            return networkInfo != null && networkInfo.isConnected();
        }

        return false;
    }
}

@@ -970,24 +970,54 @@
 networks) %7B%0A
+                    try %7B%0A    
             
@@ -1107,32 +1107,36 @@
                 
+    
 if (networkInfo 
@@ -1146,16 +1146,20 @@
 null &&%0A
+    
         
@@ -1261,16 +1261,20 @@
         
+ 
+   
 && netwo
@@ -1317,24 +1317,28 @@
             
+    
 return true;
@@ -1338,16 +1338,123 @@
 n true;%0A
+                        %7D%0A                    %7D catch (Exception e) %7B%0A                        L.report(e);%0A
         

fix one crash