Browse Source

修复代码中报错的地方

guiying712 9 years ago
parent
commit
5cc0b176a1

+ 34 - 3
Common/src/main/AndroidManifest.xml

@@ -1,7 +1,38 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.guiying.common">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.guiying.common">
 
-    <application android:allowBackup="true" android:label="@string/app_name"
-        android:supportsRtl="true">
+    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.PHONE_STATE" />
+    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
+    <uses-permission android:name="android.permission.FLASHLIGHT" />
+    <uses-permission android:name="android.permission.CALL_PHONE" />
+    <uses-permission android:name="android.permission.RECORD_AUDIO" />
+    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
+    <uses-permission android:name="com.videogo.open.permission.C2D_MESSAGE" />
+    <uses-permission android:name="android.permission.GET_TASKS" />
+
+    <uses-feature android:name="android.hardware.camera" />
+    <uses-feature android:name="android.hardware.camera.autofocus" />
+
+    <application>
+        <!--<meta-data-->
+        <!--android:name="com.common.loader.OkHttpGlideModule"-->
+        <!--android:value="GlideModule" />-->
 
     </application>
 

+ 5 - 5
common/src/main/java/com/guiying/common/base/BaseApplication.java

@@ -7,7 +7,8 @@ import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.util.Log;
 
-import com.common.util.StringUtils;
+import com.guiying.common.utils.StringUtils;
+import com.guiying.common.utils.Utils;
 import com.orhanobut.logger.LogLevel;
 import com.orhanobut.logger.Logger;
 
@@ -17,7 +18,7 @@ import java.util.Stack;
  * 要想使用BaseApplication,必须在组件中实现自己的Application,并且继承BaseApplication;
  * 组件中实现的Application必须在AndroidManifest.xml中注册,否则无法使用;
  * 组件的Application需置于java/debug文件夹中,不得放于主代码;
- * 组件中获取Context的方法必须为:BaseApplication.context,不允许其他写法;
+ * 组件中获取Context的方法必须为:Utils.getContext(),不允许其他写法;
  * BaseApplication主要有如下功能:
  * 1、全局获取Context;
  * 2、用来管理全局Activity;
@@ -30,8 +31,6 @@ public class BaseApplication extends Application {
 
     private static BaseApplication sInstance;
 
-    public static Context context;
-
     private static Stack<Activity> activityStack;
 
     public static BaseApplication getIns() {
@@ -42,7 +41,8 @@ public class BaseApplication extends Application {
     public void onCreate() {
         super.onCreate();
         sInstance = this;
-        context = this.getApplicationContext();
+        Context context = this.getApplicationContext();
+        Utils.init(context);
         if (isAppDebug(context)) {
             //只有debug模式才会打印日志
             Logger.init("Petrel").logLevel(LogLevel.FULL);

+ 0 - 7
common/src/main/java/com/guiying/common/base/BasePresenter.java

@@ -1,10 +1,3 @@
-/*
- *  @ProjectName: ISMS_Petrel_MCU
- *  @Copyright: 2016 HangZhou Hikvision System Technology Co., Ltd. All Right Reserved.
- *  @address: http://www.hikvision.com
- *  @Description: 本内容仅限于杭州海康威视系统技术公有限司内部使用,禁止转发.
- */
-
 package com.guiying.common.base;
 
 public interface BasePresenter {

+ 0 - 7
common/src/main/java/com/guiying/common/base/BaseView.java

@@ -1,10 +1,3 @@
-/*
- *  @ProjectName: ISMS_Petrel_MCU
- *  @Copyright: 2016 HangZhou Hikvision System Technology Co., Ltd. All Right Reserved.
- *  @address: http://www.hikvision.com
- *  @Description: 本内容仅限于杭州海康威视系统技术公有限司内部使用,禁止转发.
- */
-
 package com.guiying.common.base;
 
 public interface BaseView<T> {

+ 40 - 0
common/src/main/java/com/guiying/common/glide/OkHttpGlideModule.java

@@ -0,0 +1,40 @@
+package com.guiying.common.glide;
+
+import android.content.Context;
+
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.GlideBuilder;
+import com.bumptech.glide.module.GlideModule;
+
+/**
+ * A {@link GlideModule} implementation to replace Glide's default
+ * {@link java.net.HttpURLConnection} based {@link com.bumptech.glide.load.model.ModelLoader} with an OkHttp based
+ * {@link com.bumptech.glide.load.model.ModelLoader}.
+ * <p>
+ * <p>
+ * If you're using gradle, you can include this module simply by depending on the aar, the module will be merged
+ * in by manifest merger. For other build systems or for more more information, see
+ * {@link GlideModule}.
+ * </p>
+ */
+public class OkHttpGlideModule implements GlideModule {
+    @Override
+    public void applyOptions(Context context, GlideBuilder builder) {
+        // Do nothing.
+    }
+
+    @Override
+    public void registerComponents(Context context, Glide glide) {
+//        HttpsUtil.SSLParams sslParams = HttpsUtil.getSslSocketFactory(BaseApplication.context, null, , "");
+//        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+//                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
+//                .hostnameVerifier(new HostnameVerifier() {
+//                    @Override
+//                    public boolean verify(String hostname, SSLSession session) {
+//                        return true;
+//                    }
+//                })
+//                .build();
+//        glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(okHttpClient));
+    }
+}

+ 2 - 2
common/src/main/java/com/guiying/common/loader/OkHttpStreamFetcher.java → common/src/main/java/com/guiying/common/glide/OkHttpStreamFetcher.java

@@ -1,10 +1,10 @@
-package com.guiying.common.loader;
+package com.guiying.common.glide;
 
 import com.bumptech.glide.Priority;
 import com.bumptech.glide.load.data.DataFetcher;
 import com.bumptech.glide.load.model.GlideUrl;
 import com.bumptech.glide.util.ContentLengthInputStream;
-import com.common.util.CloseUtils;
+import com.guiying.common.utils.CloseUtils;
 
 import java.io.IOException;
 import java.io.InputStream;

+ 1 - 1
common/src/main/java/com/guiying/common/loader/OkHttpUrlLoader.java → common/src/main/java/com/guiying/common/glide/OkHttpUrlLoader.java

@@ -1,4 +1,4 @@
-package com.guiying.common.loader;
+package com.guiying.common.glide;
 
 import android.content.Context;
 

+ 12 - 26
common/src/main/java/com/guiying/common/http/DataParseUtil.java

@@ -1,23 +1,9 @@
-/*
- *  @ProjectName: ISMS_Petrel_MCU
- *  @Copyright: 2016 HangZhou Hikvision System Technology Co., Ltd. All Right Reserved.
- *  @address: http://www.hikvision.com
- *  @Description: 本内容仅限于杭州海康威视系统技术公有限司内部使用,禁止转发.
- */
-
 package com.guiying.common.http;
 
-import android.text.TextUtils;
-
 import com.google.gson.Gson;
 import com.google.gson.JsonObject;
 import com.google.gson.reflect.TypeToken;
 
-import org.simpleframework.xml.Serializer;
-import org.simpleframework.xml.core.Persister;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStreamReader;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -89,17 +75,17 @@ public class DataParseUtil {
      * @param json  要解析的json
      * @param clazz 解析类
      */
-    public static Object parseXml(String json, Class<?> clazz) {
-        try {
-            if (!TextUtils.isEmpty(json) && clazz != null) {
-                Serializer serializer = new Persister();
-                InputStreamReader is = new InputStreamReader(new ByteArrayInputStream(json.getBytes("UTF-8")), "utf-8");
-                return serializer.read(clazz, is);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
+//    public static Object parseXml(String json, Class<?> clazz) {
+//        try {
+//            if (!TextUtils.isEmpty(json) && clazz != null) {
+//                Serializer serializer = new Persister();
+//                InputStreamReader is = new InputStreamReader(new ByteArrayInputStream(json.getBytes("UTF-8")), "utf-8");
+//                return serializer.read(clazz, is);
+//            }
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        return null;
+//    }
 
 }

+ 12 - 13
common/src/main/java/com/guiying/common/http/HttpClient.java

@@ -2,16 +2,15 @@ package com.guiying.common.http;
 
 import android.text.TextUtils;
 
-import com.common.base.BaseApplication;
-import com.common.data.InfoCache;
-import com.common.util.NetworkUtils;
-import com.common.util.StringUtils;
-import com.common.util.ToastUtils;
 import com.franmontiel.persistentcookiejar.ClearableCookieJar;
 import com.franmontiel.persistentcookiejar.PersistentCookieJar;
 import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
 import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
-import com.hikvision.isms.petrel.common.R;
+import com.guiying.common.R;
+import com.guiying.common.utils.NetworkUtils;
+import com.guiying.common.utils.StringUtils;
+import com.guiying.common.utils.ToastUtils;
+import com.guiying.common.utils.Utils;
 import com.orhanobut.logger.Logger;
 
 import java.io.IOException;
@@ -48,7 +47,7 @@ public class HttpClient {
     /*返回数据为xml类型*/
     public static final int XML = 3;
     /*用户设置的BASE_URL*/
-    public static String BASE_URL = InfoCache.getIns().getBaseUrl();
+    public static String BASE_URL = "";
     /*本地使用的baseUrl*/
     private String baseUrl = "";
     private static OkHttpClient okHttpClient;
@@ -74,11 +73,11 @@ public class HttpClient {
     }
 
     private HttpClient() {
-        ClearableCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(BaseApplication.getIns()));
-        //HttpsUtil.SSLParams sslParams = HttpsUtil.getSslSocketFactory(BaseApplication.context, new int[0], R.raw.ivms8700, STORE_PASS);
+        ClearableCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(Utils.getContext()));
+        //HttpsUtil.SSLParams sslParams = HttpsUtil.getSslSocketFactory(BaseApplication.context, new int[0], , );
         okHttpClient = new OkHttpClient.Builder()
                 .connectTimeout(10000L, TimeUnit.MILLISECONDS)
-                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
+                //.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
                 .hostnameVerifier(HttpsUtil.getHostnameVerifier())
                 .addInterceptor(new LoggerInterceptor(null, true))
                 .cookieJar(cookieJar)
@@ -245,10 +244,10 @@ public class HttpClient {
         }
 
         /**
-         * 如需设置baseUrl请使用这种方法:HttpClient.BASE_URL = "https://10.33.31.200:8890/";
+         * 如需设置baseUrl请使用这种方法:HttpClient.BASE_URL = "http://000000000000/";
          * 不推荐使用下面的方法改变baseUrl的值。
          * 请求地址的baseUrl,最后会被赋值给HttpClient的静态变量BASE_URL;
-         * 例如:"https://10.33.31.200:8890/"
+         * 例如:"https://00000000000/"
          *
          * @param baseUrl 请求地址的baseUrl
          */
@@ -327,7 +326,7 @@ public class HttpClient {
                 onResultListener.onSuccess(DataParseUtil.parseToArrayList(data, clazz));
                 break;
             case XML:
-                onResultListener.onSuccess(DataParseUtil.parseXml(data, clazz));
+                //onResultListener.onSuccess(DataParseUtil.parseXml(data, clazz));
                 break;
             default:
                 Logger.e("http parse tip:", "if you want return object, please use bodyType() set data type");

+ 0 - 51
common/src/main/java/com/guiying/common/loader/OkHttpGlideModule.java

@@ -1,51 +0,0 @@
-package com.guiying.common.loader;
-
-import android.content.Context;
-
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.GlideBuilder;
-import com.bumptech.glide.load.model.GlideUrl;
-import com.bumptech.glide.module.GlideModule;
-import com.common.base.BaseApplication;
-import com.common.http.HttpsUtil;
-import com.hikvision.isms.petrel.common.R;
-
-import java.io.InputStream;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.SSLSession;
-
-import okhttp3.OkHttpClient;
-
-/**
- * A {@link GlideModule} implementation to replace Glide's default
- * {@link java.net.HttpURLConnection} based {@link com.bumptech.glide.load.model.ModelLoader} with an OkHttp based
- * {@link com.bumptech.glide.load.model.ModelLoader}.
- * <p>
- * <p>
- * If you're using gradle, you can include this module simply by depending on the aar, the module will be merged
- * in by manifest merger. For other build systems or for more more information, see
- * {@link GlideModule}.
- * </p>
- */
-public class OkHttpGlideModule implements GlideModule {
-    @Override
-    public void applyOptions(Context context, GlideBuilder builder) {
-        // Do nothing.
-    }
-
-    @Override
-    public void registerComponents(Context context, Glide glide) {
-        HttpsUtil.SSLParams sslParams = HttpsUtil.getSslSocketFactory(BaseApplication.context, null, R.raw.ivms8700, "");
-        OkHttpClient okHttpClient = new OkHttpClient.Builder()
-                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
-                .hostnameVerifier(new HostnameVerifier() {
-                    @Override
-                    public boolean verify(String hostname, SSLSession session) {
-                        return true;
-                    }
-                })
-                .build();
-        glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(okHttpClient));
-    }
-}

+ 54 - 0
common/src/main/java/com/guiying/common/utils/CloseUtils.java

@@ -0,0 +1,54 @@
+package com.guiying.common.utils;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * <pre>
+ *     author: Blankj
+ *     blog  : http://blankj.com
+ *     time  : 2016/10/9
+ *     desc  : 关闭相关工具类
+ * </pre>
+ */
+public class CloseUtils {
+
+    private CloseUtils() {
+        throw new UnsupportedOperationException("u can't instantiate me...");
+    }
+
+    /**
+     * 关闭IO
+     *
+     * @param closeables closeable
+     */
+    public static void closeIO(Closeable... closeables) {
+        if (closeables == null) return;
+        for (Closeable closeable : closeables) {
+            if (closeable != null) {
+                try {
+                    closeable.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 安静关闭IO
+     *
+     * @param closeables closeable
+     */
+    public static void closeIOQuietly(Closeable... closeables) {
+        if (closeables == null) return;
+        for (Closeable closeable : closeables) {
+            if (closeable != null) {
+                try {
+                    closeable.close();
+                } catch (IOException ignored) {
+                }
+            }
+        }
+    }
+}

+ 347 - 0
common/src/main/java/com/guiying/common/utils/NetworkUtils.java

@@ -0,0 +1,347 @@
+package com.guiying.common.utils;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiManager;
+import android.telephony.TelephonyManager;
+
+import com.orhanobut.logger.Logger;
+
+import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+/**
+ * <pre>
+ *     author: Blankj
+ *     blog  : http://blankj.com
+ *     time  : 2016/8/2
+ *     desc  : 网络相关工具类
+ * </pre>
+ */
+public class NetworkUtils {
+
+    private NetworkUtils() {
+        throw new UnsupportedOperationException("u can't instantiate me...");
+    }
+
+    public enum NetworkType {
+        NETWORK_WIFI,
+        NETWORK_4G,
+        NETWORK_3G,
+        NETWORK_2G,
+        NETWORK_UNKNOWN,
+        NETWORK_NO
+    }
+
+    /**
+     * 打开网络设置界面
+     * <p>3.0以下打开设置界面</p>
+     */
+    public static void openWirelessSettings() {
+        if (android.os.Build.VERSION.SDK_INT > 10) {
+            Utils.getContext().startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+        } else {
+            Utils.getContext().startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+        }
+    }
+
+    /**
+     * 获取活动网络信息
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
+     *
+     * @return NetworkInfo
+     */
+    private static NetworkInfo getActiveNetworkInfo() {
+        return ((ConnectivityManager) Utils.getContext().getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
+    }
+
+    /**
+     * 判断网络是否连接
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
+     *
+     * @return {@code true}: 是<br>{@code false}: 否
+     */
+    public static boolean isConnected() {
+        NetworkInfo info = getActiveNetworkInfo();
+        return info != null && info.isConnected();
+    }
+
+    /**
+     * 判断网络是否可用
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
+     *
+     * @return {@code true}: 可用<br>{@code false}: 不可用
+     */
+    public static boolean isAvailableByPing() {
+        ShellUtils.CommandResult result = ShellUtils.execCmd("ping -c 1 -w 1 223.5.5.5", false);
+        boolean ret = result.result == 0;
+        if (result.errorMsg != null) {
+            Logger.d("isAvailableByPing errorMsg", result.errorMsg);
+        }
+        if (result.successMsg != null) {
+            Logger.d("isAvailableByPing successMsg", result.successMsg);
+        }
+        return ret;
+    }
+
+    /**
+     * 判断移动数据是否打开
+     *
+     * @return {@code true}: 是<br>{@code false}: 否
+     */
+    public static boolean getDataEnabled() {
+        try {
+            TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
+            Method getMobileDataEnabledMethod = tm.getClass().getDeclaredMethod("getDataEnabled");
+            if (null != getMobileDataEnabledMethod) {
+                return (boolean) getMobileDataEnabledMethod.invoke(tm);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+    /**
+     * 打开或关闭移动数据
+     * <p>需系统应用 需添加权限{@code <uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>}</p>
+     *
+     * @param enabled {@code true}: 打开<br>{@code false}: 关闭
+     */
+    public static void setDataEnabled(boolean enabled) {
+        try {
+            TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
+            Method setMobileDataEnabledMethod = tm.getClass().getDeclaredMethod("setDataEnabled", boolean.class);
+            if (null != setMobileDataEnabledMethod) {
+                setMobileDataEnabledMethod.invoke(tm, enabled);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 判断网络是否是4G
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
+     *
+     * @return {@code true}: 是<br>{@code false}: 否
+     */
+    public static boolean is4G() {
+        NetworkInfo info = getActiveNetworkInfo();
+        return info != null && info.isAvailable() && info.getSubtype() == TelephonyManager.NETWORK_TYPE_LTE;
+    }
+
+    /**
+     * 判断wifi是否打开
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>}</p>
+     *
+     * @return {@code true}: 是<br>{@code false}: 否
+     */
+    public static boolean getWifiEnabled() {
+        WifiManager wifiManager = (WifiManager) Utils.getContext().getSystemService(Context.WIFI_SERVICE);
+        return wifiManager.isWifiEnabled();
+    }
+
+    /**
+     * 打开或关闭wifi
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>}</p>
+     *
+     * @param enabled {@code true}: 打开<br>{@code false}: 关闭
+     */
+    public static void setWifiEnabled(boolean enabled) {
+        WifiManager wifiManager = (WifiManager) Utils.getContext().getSystemService(Context.WIFI_SERVICE);
+        if (enabled) {
+            if (!wifiManager.isWifiEnabled()) {
+                wifiManager.setWifiEnabled(true);
+            }
+        } else {
+            if (wifiManager.isWifiEnabled()) {
+                wifiManager.setWifiEnabled(false);
+            }
+        }
+    }
+
+    /**
+     * 判断wifi是否连接状态
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
+     *
+     * @return {@code true}: 连接<br>{@code false}: 未连接
+     */
+    public static boolean isWifiConnected() {
+        ConnectivityManager cm = (ConnectivityManager) Utils.getContext()
+                .getSystemService(Context.CONNECTIVITY_SERVICE);
+        return cm != null && cm.getActiveNetworkInfo() != null
+                && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI;
+    }
+
+    /**
+     * 判断wifi数据是否可用
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>}</p>
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
+     *
+     * @return {@code true}: 是<br>{@code false}: 否
+     */
+    public static boolean isWifiAvailable() {
+        return getWifiEnabled() && isAvailableByPing();
+    }
+
+    /**
+     * 获取网络运营商名称
+     * <p>中国移动、如中国联通、中国电信</p>
+     *
+     * @return 运营商名称
+     */
+    public static String getNetworkOperatorName() {
+        TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
+        return tm != null ? tm.getNetworkOperatorName() : null;
+    }
+
+    private static final int NETWORK_TYPE_GSM = 16;
+    private static final int NETWORK_TYPE_TD_SCDMA = 17;
+    private static final int NETWORK_TYPE_IWLAN = 18;
+
+    /**
+     * 获取当前网络类型
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
+     *
+     * @return 网络类型
+     * <ul>
+     * <li>{@link NetworkUtils.NetworkType#NETWORK_WIFI   } </li>
+     * <li>{@link NetworkUtils.NetworkType#NETWORK_4G     } </li>
+     * <li>{@link NetworkUtils.NetworkType#NETWORK_3G     } </li>
+     * <li>{@link NetworkUtils.NetworkType#NETWORK_2G     } </li>
+     * <li>{@link NetworkUtils.NetworkType#NETWORK_UNKNOWN} </li>
+     * <li>{@link NetworkUtils.NetworkType#NETWORK_NO     } </li>
+     * </ul>
+     */
+    public static NetworkType getNetworkType() {
+        NetworkType netType = NetworkType.NETWORK_NO;
+        NetworkInfo info = getActiveNetworkInfo();
+        if (info != null && info.isAvailable()) {
+
+            if (info.getType() == ConnectivityManager.TYPE_WIFI) {
+                netType = NetworkType.NETWORK_WIFI;
+            } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
+                switch (info.getSubtype()) {
+
+                    case NETWORK_TYPE_GSM:
+                    case TelephonyManager.NETWORK_TYPE_GPRS:
+                    case TelephonyManager.NETWORK_TYPE_CDMA:
+                    case TelephonyManager.NETWORK_TYPE_EDGE:
+                    case TelephonyManager.NETWORK_TYPE_1xRTT:
+                    case TelephonyManager.NETWORK_TYPE_IDEN:
+                        netType = NetworkType.NETWORK_2G;
+                        break;
+
+                    case NETWORK_TYPE_TD_SCDMA:
+                    case TelephonyManager.NETWORK_TYPE_EVDO_A:
+                    case TelephonyManager.NETWORK_TYPE_UMTS:
+                    case TelephonyManager.NETWORK_TYPE_EVDO_0:
+                    case TelephonyManager.NETWORK_TYPE_HSDPA:
+                    case TelephonyManager.NETWORK_TYPE_HSUPA:
+                    case TelephonyManager.NETWORK_TYPE_HSPA:
+                    case TelephonyManager.NETWORK_TYPE_EVDO_B:
+                    case TelephonyManager.NETWORK_TYPE_EHRPD:
+                    case TelephonyManager.NETWORK_TYPE_HSPAP:
+                        netType = NetworkType.NETWORK_3G;
+                        break;
+
+                    case NETWORK_TYPE_IWLAN:
+                    case TelephonyManager.NETWORK_TYPE_LTE:
+                        netType = NetworkType.NETWORK_4G;
+                        break;
+                    default:
+
+                        String subtypeName = info.getSubtypeName();
+                        if (subtypeName.equalsIgnoreCase("TD-SCDMA")
+                                || subtypeName.equalsIgnoreCase("WCDMA")
+                                || subtypeName.equalsIgnoreCase("CDMA2000")) {
+                            netType = NetworkType.NETWORK_3G;
+                        } else {
+                            netType = NetworkType.NETWORK_UNKNOWN;
+                        }
+                        break;
+                }
+            } else {
+                netType = NetworkType.NETWORK_UNKNOWN;
+            }
+        }
+        return netType;
+    }
+
+    /**
+     * 获取IP地址
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
+     *
+     * @param useIPv4 是否用IPv4
+     * @return IP地址
+     */
+    public static String getIPAddress(boolean useIPv4) {
+        try {
+            for (Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces(); nis.hasMoreElements(); ) {
+                NetworkInterface ni = nis.nextElement();
+                // 防止小米手机返回10.0.2.15
+                if (!ni.isUp()) continue;
+                for (Enumeration<InetAddress> addresses = ni.getInetAddresses(); addresses.hasMoreElements(); ) {
+                    InetAddress inetAddress = addresses.nextElement();
+                    if (!inetAddress.isLoopbackAddress()) {
+                        String hostAddress = inetAddress.getHostAddress();
+                        boolean isIPv4 = hostAddress.indexOf(':') < 0;
+                        if (useIPv4) {
+                            if (isIPv4) return hostAddress;
+                        } else {
+                            if (!isIPv4) {
+                                int index = hostAddress.indexOf('%');
+                                return index < 0 ? hostAddress.toUpperCase() : hostAddress.substring(0, index).toUpperCase();
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (SocketException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 获取域名ip地址
+     * <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
+     *
+     * @param domain 域名
+     * @return ip地址
+     */
+    public static String getDomainAddress(final String domain) {
+        try {
+            ExecutorService exec = Executors.newCachedThreadPool();
+            Future<String> fs = exec.submit(new Callable<String>() {
+                @Override
+                public String call() throws Exception {
+                    InetAddress inetAddress;
+                    try {
+                        inetAddress = InetAddress.getByName(domain);
+                        return inetAddress.getHostAddress();
+                    } catch (UnknownHostException e) {
+                        e.printStackTrace();
+                    }
+                    return null;
+                }
+            });
+            return fs.get();
+        } catch (InterruptedException | ExecutionException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 161 - 0
common/src/main/java/com/guiying/common/utils/ShellUtils.java

@@ -0,0 +1,161 @@
+package com.guiying.common.utils;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+
+/**
+ * <pre>
+ *     author: Blankj
+ *     blog  : http://blankj.com
+ *     time  : 2016/8/7
+ *     desc  : Shell相关工具类
+ * </pre>
+ */
+public class ShellUtils {
+
+    private ShellUtils() {
+        throw new UnsupportedOperationException("u can't instantiate me...");
+    }
+
+    /**
+     * 是否是在root下执行命令
+     *
+     * @param command 命令
+     * @param isRoot  是否需要root权限执行
+     * @return CommandResult
+     */
+    public static CommandResult execCmd(String command, boolean isRoot) {
+        return execCmd(new String[]{command}, isRoot, true);
+    }
+
+    /**
+     * 是否是在root下执行命令
+     *
+     * @param commands 多条命令链表
+     * @param isRoot   是否需要root权限执行
+     * @return CommandResult
+     */
+    public static CommandResult execCmd(List<String> commands, boolean isRoot) {
+        return execCmd(commands == null ? null : commands.toArray(new String[]{}), isRoot, true);
+    }
+
+    /**
+     * 是否是在root下执行命令
+     *
+     * @param commands 多条命令数组
+     * @param isRoot   是否需要root权限执行
+     * @return CommandResult
+     */
+    public static CommandResult execCmd(String[] commands, boolean isRoot) {
+        return execCmd(commands, isRoot, true);
+    }
+
+    /**
+     * 是否是在root下执行命令
+     *
+     * @param command         命令
+     * @param isRoot          是否需要root权限执行
+     * @param isNeedResultMsg 是否需要结果消息
+     * @return CommandResult
+     */
+    public static CommandResult execCmd(String command, boolean isRoot, boolean isNeedResultMsg) {
+        return execCmd(new String[]{command}, isRoot, isNeedResultMsg);
+    }
+
+    /**
+     * 是否是在root下执行命令
+     *
+     * @param commands        命令链表
+     * @param isRoot          是否需要root权限执行
+     * @param isNeedResultMsg 是否需要结果消息
+     * @return CommandResult
+     */
+    public static CommandResult execCmd(List<String> commands, boolean isRoot, boolean isNeedResultMsg) {
+        return execCmd(commands == null ? null : commands.toArray(new String[]{}), isRoot, isNeedResultMsg);
+    }
+
+    /**
+     * 是否是在root下执行命令
+     *
+     * @param commands        命令数组
+     * @param isRoot          是否需要root权限执行
+     * @param isNeedResultMsg 是否需要结果消息
+     * @return CommandResult
+     */
+    public static CommandResult execCmd(String[] commands, boolean isRoot, boolean isNeedResultMsg) {
+        int result = -1;
+        if (commands == null || commands.length == 0) {
+            return new CommandResult(result, null, null);
+        }
+        Process process = null;
+        BufferedReader successResult = null;
+        BufferedReader errorResult = null;
+        StringBuilder successMsg = null;
+        StringBuilder errorMsg = null;
+        DataOutputStream os = null;
+        try {
+            process = Runtime.getRuntime().exec(isRoot ? "su" : "sh");
+            os = new DataOutputStream(process.getOutputStream());
+            for (String command : commands) {
+                if (command == null) continue;
+                os.write(command.getBytes());
+                os.writeBytes("\n");
+                os.flush();
+            }
+            os.writeBytes("exit\n");
+            os.flush();
+            result = process.waitFor();
+            if (isNeedResultMsg) {
+                successMsg = new StringBuilder();
+                errorMsg = new StringBuilder();
+                successResult = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
+                errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream(), "UTF-8"));
+                String s;
+                while ((s = successResult.readLine()) != null) {
+                    successMsg.append(s);
+                }
+                while ((s = errorResult.readLine()) != null) {
+                    errorMsg.append(s);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            CloseUtils.closeIO(os, successResult, errorResult);
+            if (process != null) {
+                process.destroy();
+            }
+        }
+        return new CommandResult(
+                result,
+                successMsg == null ? null : successMsg.toString(),
+                errorMsg == null ? null : errorMsg.toString()
+        );
+    }
+
+    /**
+     * 返回的命令结果
+     */
+    public static class CommandResult {
+        /**
+         * 结果码
+         **/
+        public int result;
+        /**
+         * 成功信息
+         **/
+        public String successMsg;
+        /**
+         * 错误信息
+         **/
+        public String errorMsg;
+
+        public CommandResult(int result, String successMsg, String errorMsg) {
+            this.result = result;
+            this.successMsg = successMsg;
+            this.errorMsg = errorMsg;
+        }
+    }
+}

+ 197 - 0
common/src/main/java/com/guiying/common/utils/StringUtils.java

@@ -0,0 +1,197 @@
+package com.guiying.common.utils;
+
+/**
+ * <pre>
+ *     author: Blankj
+ *     blog  : http://blankj.com
+ *     time  : 2016/8/16
+ *     desc  : 字符串相关工具类
+ * </pre>
+ */
+public class StringUtils {
+
+    private StringUtils() {
+        throw new UnsupportedOperationException("u can't instantiate me...");
+    }
+
+    /**
+     * 字符串拼接,线程安全
+     */
+    public static String buffer(String... array) {
+        StringBuffer s = new StringBuffer();
+        for (String str : array) {
+            s.append(str);
+        }
+        return s.toString();
+    }
+
+    /**
+     * 字符串拼接,线程不安全,效率高
+     */
+    public static String builder(String... array) {
+        StringBuilder s = new StringBuilder();
+        for (String str : array) {
+            s.append(str);
+        }
+        return s.toString();
+    }
+
+
+    /**
+     * 判断字符串是否为null或长度为0
+     *
+     * @param s 待校验字符串
+     * @return {@code true}: 空<br> {@code false}: 不为空
+     */
+    public static boolean isEmpty(CharSequence s) {
+        return s == null || s.length() == 0;
+    }
+
+    /**
+     * 判断字符串是否为null或全为空格
+     *
+     * @param s 待校验字符串
+     * @return {@code true}: null或全空格<br> {@code false}: 不为null且不全空格
+     */
+    public static boolean isSpace(String s) {
+        return (s == null || s.trim().length() == 0);
+    }
+
+    /**
+     * 判断两字符串是否相等
+     *
+     * @param a 待校验字符串a
+     * @param b 待校验字符串b
+     * @return {@code true}: 相等<br>{@code false}: 不相等
+     */
+    public static boolean equals(CharSequence a, CharSequence b) {
+        if (a == b) return true;
+        int length;
+        if (a != null && b != null && (length = a.length()) == b.length()) {
+            if (a instanceof String && b instanceof String) {
+                return a.equals(b);
+            } else {
+                for (int i = 0; i < length; i++) {
+                    if (a.charAt(i) != b.charAt(i)) return false;
+                }
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 判断两字符串忽略大小写是否相等
+     *
+     * @param a 待校验字符串a
+     * @param b 待校验字符串b
+     * @return {@code true}: 相等<br>{@code false}: 不相等
+     */
+    public static boolean equalsIgnoreCase(String a, String b) {
+        return (a == b) || (b != null) && (a.length() == b.length()) && a.regionMatches(true, 0, b, 0, b.length());
+    }
+
+    /**
+     * null转为长度为0的字符串
+     *
+     * @param s 待转字符串
+     * @return s为null转为长度为0字符串,否则不改变
+     */
+    public static String null2Length0(String s) {
+        return s == null ? "" : s;
+    }
+
+    /**
+     * 返回字符串长度
+     *
+     * @param s 字符串
+     * @return null返回0,其他返回自身长度
+     */
+    public static int length(CharSequence s) {
+        return s == null ? 0 : s.length();
+    }
+
+    /**
+     * 首字母大写
+     *
+     * @param s 待转字符串
+     * @return 首字母大写字符串
+     */
+    public static String upperFirstLetter(String s) {
+        if (isEmpty(s) || !Character.isLowerCase(s.charAt(0))) return s;
+        return String.valueOf((char) (s.charAt(0) - 32)) + s.substring(1);
+    }
+
+    /**
+     * 首字母小写
+     *
+     * @param s 待转字符串
+     * @return 首字母小写字符串
+     */
+    public static String lowerFirstLetter(String s) {
+        if (isEmpty(s) || !Character.isUpperCase(s.charAt(0))) return s;
+        return String.valueOf((char) (s.charAt(0) + 32)) + s.substring(1);
+    }
+
+    /**
+     * 反转字符串
+     *
+     * @param s 待反转字符串
+     * @return 反转字符串
+     */
+    public static String reverse(String s) {
+        int len = length(s);
+        if (len <= 1) return s;
+        int mid = len >> 1;
+        char[] chars = s.toCharArray();
+        char c;
+        for (int i = 0; i < mid; ++i) {
+            c = chars[i];
+            chars[i] = chars[len - i - 1];
+            chars[len - i - 1] = c;
+        }
+        return new String(chars);
+    }
+
+    /**
+     * 转化为半角字符
+     *
+     * @param s 待转字符串
+     * @return 半角字符串
+     */
+    public static String toDBC(String s) {
+        if (isEmpty(s)) return s;
+        char[] chars = s.toCharArray();
+        for (int i = 0, len = chars.length; i < len; i++) {
+            if (chars[i] == 12288) {
+                chars[i] = ' ';
+            } else if (65281 <= chars[i] && chars[i] <= 65374) {
+                chars[i] = (char) (chars[i] - 65248);
+            } else {
+                chars[i] = chars[i];
+            }
+        }
+        return new String(chars);
+    }
+
+    /**
+     * 转化为全角字符
+     *
+     * @param s 待转字符串
+     * @return 全角字符串
+     */
+    public static String toSBC(String s) {
+        if (isEmpty(s)) return s;
+        char[] chars = s.toCharArray();
+        for (int i = 0, len = chars.length; i < len; i++) {
+            if (chars[i] == ' ') {
+                chars[i] = (char) 12288;
+            } else if (33 <= chars[i] && chars[i] <= 126) {
+                chars[i] = (char) (chars[i] + 65248);
+            } else {
+                chars[i] = chars[i];
+            }
+        }
+        return new String(chars);
+    }
+}

+ 287 - 0
common/src/main/java/com/guiying/common/utils/ToastUtils.java

@@ -0,0 +1,287 @@
+package com.guiying.common.utils;
+
+import android.os.Handler;
+import android.os.Looper;
+import android.support.annotation.StringRes;
+import android.widget.Toast;
+
+/**
+ * <pre>
+ *     author: Blankj
+ *     blog  : http://blankj.com
+ *     time  : 2016/9/29
+ *     desc  : 吐司相关工具类
+ * </pre>
+ */
+public class ToastUtils {
+
+    private ToastUtils() {
+        throw new UnsupportedOperationException("u can't instantiate me...");
+    }
+
+    private static Toast sToast;
+    private static Handler sHandler = new Handler(Looper.getMainLooper());
+    private static boolean isJumpWhenMore;
+
+    /**
+     * 吐司初始化
+     *
+     * @param isJumpWhenMore 当连续弹出吐司时,是要弹出新吐司还是只修改文本内容
+     *                       <p>{@code true}: 弹出新吐司<br>{@code false}: 只修改文本内容</p>
+     *                       <p>如果为{@code false}的话可用来做显示任意时长的吐司</p>
+     */
+    public static void init(boolean isJumpWhenMore) {
+        ToastUtils.isJumpWhenMore = isJumpWhenMore;
+    }
+
+    /**
+     * 安全地显示短时吐司
+     *
+     * @param text 文本
+     */
+    public static void showShortToastSafe(final CharSequence text) {
+        sHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                showToast(text, Toast.LENGTH_SHORT);
+            }
+        });
+    }
+
+    /**
+     * 安全地显示短时吐司
+     *
+     * @param resId 资源Id
+     */
+    public static void showShortToastSafe(final @StringRes int resId) {
+        sHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                showToast(resId, Toast.LENGTH_SHORT);
+            }
+        });
+    }
+
+    /**
+     * 安全地显示短时吐司
+     *
+     * @param resId 资源Id
+     * @param args  参数
+     */
+    public static void showShortToastSafe(final @StringRes int resId, final Object... args) {
+        sHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                showToast(resId, Toast.LENGTH_SHORT, args);
+            }
+        });
+    }
+
+    /**
+     * 安全地显示短时吐司
+     *
+     * @param format 格式
+     * @param args   参数
+     */
+    public static void showShortToastSafe(final String format, final Object... args) {
+        sHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                showToast(format, Toast.LENGTH_SHORT, args);
+            }
+        });
+    }
+
+    /**
+     * 安全地显示长时吐司
+     *
+     * @param text 文本
+     */
+    public static void showLongToastSafe(final CharSequence text) {
+        sHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                showToast(text, Toast.LENGTH_LONG);
+            }
+        });
+    }
+
+    /**
+     * 安全地显示长时吐司
+     *
+     * @param resId 资源Id
+     */
+    public static void showLongToastSafe(final @StringRes int resId) {
+        sHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                showToast(resId, Toast.LENGTH_LONG);
+            }
+        });
+    }
+
+    /**
+     * 安全地显示长时吐司
+     *
+     * @param resId 资源Id
+     * @param args  参数
+     */
+    public static void showLongToastSafe(final @StringRes int resId, final Object... args) {
+        sHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                showToast(resId, Toast.LENGTH_LONG, args);
+            }
+        });
+    }
+
+    /**
+     * 安全地显示长时吐司
+     *
+     * @param format 格式
+     * @param args   参数
+     */
+    public static void showLongToastSafe(final String format, final Object... args) {
+        sHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                showToast(format, Toast.LENGTH_LONG, args);
+            }
+        });
+    }
+
+    /**
+     * 显示短时吐司
+     *
+     * @param text 文本
+     */
+    public static void showShortToast(CharSequence text) {
+        showToast(text, Toast.LENGTH_SHORT);
+    }
+
+    /**
+     * 显示短时吐司
+     *
+     * @param resId 资源Id
+     */
+    public static void showShortToast(@StringRes int resId) {
+        showToast(resId, Toast.LENGTH_SHORT);
+    }
+
+    /**
+     * 显示短时吐司
+     *
+     * @param resId 资源Id
+     * @param args  参数
+     */
+    public static void showShortToast(@StringRes int resId, Object... args) {
+        showToast(resId, Toast.LENGTH_SHORT, args);
+    }
+
+    /**
+     * 显示短时吐司
+     *
+     * @param format 格式
+     * @param args   参数
+     */
+    public static void showShortToast(String format, Object... args) {
+        showToast(format, Toast.LENGTH_SHORT, args);
+    }
+
+    /**
+     * 显示长时吐司
+     *
+     * @param text 文本
+     */
+    public static void showLongToast(CharSequence text) {
+        showToast(text, Toast.LENGTH_LONG);
+    }
+
+    /**
+     * 显示长时吐司
+     *
+     * @param resId 资源Id
+     */
+    public static void showLongToast(@StringRes int resId) {
+        showToast(resId, Toast.LENGTH_LONG);
+    }
+
+    /**
+     * 显示长时吐司
+     *
+     * @param resId 资源Id
+     * @param args  参数
+     */
+    public static void showLongToast(@StringRes int resId, Object... args) {
+        showToast(resId, Toast.LENGTH_LONG, args);
+    }
+
+    /**
+     * 显示长时吐司
+     *
+     * @param format 格式
+     * @param args   参数
+     */
+    public static void showLongToast(String format, Object... args) {
+        showToast(format, Toast.LENGTH_LONG, args);
+    }
+
+    /**
+     * 显示吐司
+     *
+     * @param resId    资源Id
+     * @param duration 显示时长
+     */
+    private static void showToast(@StringRes int resId, int duration) {
+        showToast(Utils.getContext().getResources().getText(resId).toString(), duration);
+    }
+
+    /**
+     * 显示吐司
+     *
+     * @param resId    资源Id
+     * @param duration 显示时长
+     * @param args     参数
+     */
+    private static void showToast(@StringRes int resId, int duration, Object... args) {
+        showToast(String.format(Utils.getContext().getResources().getString(resId), args), duration);
+    }
+
+    /**
+     * 显示吐司
+     *
+     * @param format   格式
+     * @param duration 显示时长
+     * @param args     参数
+     */
+    private static void showToast(String format, int duration, Object... args) {
+        showToast(String.format(format, args), duration);
+    }
+
+    /**
+     * 显示吐司
+     *
+     * @param text     文本
+     * @param duration 显示时长
+     */
+    private static void showToast(CharSequence text, int duration) {
+        if (isJumpWhenMore) cancelToast();
+        if (sToast == null) {
+            sToast = Toast.makeText(Utils.getContext(), text, duration);
+        } else {
+            sToast.setText(text);
+            sToast.setDuration(duration);
+        }
+        sToast.show();
+    }
+
+    /**
+     * 取消吐司显示
+     */
+    public static void cancelToast() {
+        if (sToast != null) {
+            sToast.cancel();
+            sToast = null;
+        }
+    }
+}

+ 41 - 0
common/src/main/java/com/guiying/common/utils/Utils.java

@@ -0,0 +1,41 @@
+package com.guiying.common.utils;
+
+import android.content.Context;
+
+/**
+ * <pre>
+ *     author: Blankj
+ *     blog  : http://blankj.com
+ *     time  : 16/12/08
+ *     desc  : Utils初始化相关
+ * </pre>
+ */
+public class Utils {
+
+    private static Context context;
+
+
+    private Utils() {
+        throw new UnsupportedOperationException("u can't instantiate me...");
+    }
+
+    /**
+     * 初始化工具类
+     *
+     * @param context 上下文
+     */
+    public static void init(Context context) {
+        Utils.context = context.getApplicationContext();
+    }
+
+    /**
+     * 获取ApplicationContext
+     *
+     * @return ApplicationContext
+     */
+    public static Context getContext() {
+        if (context != null) return context;
+        throw new NullPointerException("u should init first");
+    }
+
+}

+ 2 - 0
girls/src/main/java/com/guiying/girls/Girls.java

@@ -1,5 +1,7 @@
 package com.guiying.girls;
 
+import com.github.mzule.activityrouter.annotation.Module;
+
 /**
  * <p>类说明</p>
  *

+ 2 - 0
news/src/main/java/com/guiying/news/news.java

@@ -1,5 +1,7 @@
 package com.guiying.news;
 
+import com.github.mzule.activityrouter.annotation.Module;
+
 /**
  * <p>类说明</p>
  *