hanjing 6 rokov pred
rodič
commit
ee241c898e

+ 3 - 0
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -545,4 +545,7 @@ public class KFZSJs {
             }
         });
     }
+
+//    @JavascriptInterface
+//    public void put
 }

+ 32 - 34
app/src/main/java/com/sheep/jiuyan/samllsheep/utils/G.java

@@ -69,59 +69,55 @@ public class G {
      * @param duration 显示的时长
      */
     public static void showToast(String msg, int duration) {
-        if(TextUtils.isEmpty(msg)){
+        if (TextUtils.isEmpty(msg)) {
+            return;
+        }
+        if (msg.contains("<html>")) {
             return;
         }
         Toast.makeText(SheepApp.getInstance(), msg, duration).show();
-//        if (mToast == null) {
-//            mToast = Toast.makeText(SheepApp.getInstance(), msg, duration);
-//            mToast.setGravity(Gravity.CENTER, 0, getRealPix(200));//居中靠下
-//            if (mToast.getView() instanceof ViewGroup
-//                    && ((ViewGroup) mToast.getView()).getChildAt(0) instanceof TextView) {
-//                ((TextView) ((ViewGroup) mToast.getView()).getChildAt(0)).setSingleLine(false);
-//            }
-//        } else if (msg == null || msg.equals(""))
-//            mToast.cancel();
-//        else {
-//            mToast.setText(msg);
-//        }
-//        mToast.show();
     }
 
-    public static void shortToast(BaseMessage msg){
-        if(TextUtils.isEmpty(msg.getMsg())){
+    public static void shortToast(BaseMessage msg) {
+        if (TextUtils.isEmpty(msg.getMsg())) {
             G.shortToast(SheepApp.getInstance().getString(R.string.unknown_error));
+        } else if(msg.getCode() == 404 || msg.getCode() == 503) {
+            G.shortToast("错误: " + msg.getCode());
         } else {
             G.shortToast(msg.getMsg() + (BuildConfig.DEBUG ? "[" + msg.getCode() + "]" : ""));
         }
     }
 
-    public static void shortToast(String msg){
-        Toast t = Toast.makeText(SheepApp.getInstance(), msg, Toast.LENGTH_SHORT);
-        t.setGravity(Gravity.CENTER, 0, getRealPix(200));//居中靠下
-        t.show();
+    public static void shortToast(String msg) {
+        showToast(msg);
     }
 
     public static void showToast(String msg) {
         showToast(msg, Toast.LENGTH_SHORT);
     }
+
     public static void showToast(int resId) {
         showToast(SheepApp.getInstance().getString(resId), Toast.LENGTH_SHORT);
     }
+
     public static void showToast(BaseMessage baseMessage) {
-        if(TextUtils.isEmpty(baseMessage.getMsg())){
+        if (TextUtils.isEmpty(baseMessage.getMsg())) {
             G.showToast(R.string.unknown_error);
+        } else if(baseMessage.getCode() == 404 || baseMessage.getCode() == 503) {
+            G.shortToast("错误: " + baseMessage.getCode());
         } else {
             G.showToast(baseMessage.getMsg() + (BuildConfig.DEBUG ? "[" + baseMessage.getCode() + "]" : ""));
         }
     }
+
     public static void showToast(Throwable throwable) {
-        if(throwable != null && !TextUtils.isEmpty(throwable.getMessage())){
+        if (throwable != null && !TextUtils.isEmpty(throwable.getMessage())) {
             G.showToast(throwable.getMessage());
         } else {
             G.showToast(R.string.unknown_error);
         }
     }
+
     /**
      * 通过反射,获取包含虚拟键的整体屏幕高度
      *
@@ -144,6 +140,7 @@ public class G {
         }
         return dpi;
     }
+
     /**
      * 获取屏幕尺寸,但是不包括虚拟功能高度
      *
@@ -156,6 +153,7 @@ public class G {
 
     /**
      * 获取是否存在NavigationBar
+     *
      * @param context
      * @return
      */
@@ -181,8 +179,6 @@ public class G {
     }
 
 
-
-
     /**
      * 获取剩余空间
      *
@@ -199,6 +195,7 @@ public class G {
         }
         return sizes / ((1024 * 1024));
     }
+
     public static long getFreeSpaceB() {
         File file = Environment.getDataDirectory();
         StatFs dataFs = new StatFs(file.getPath());
@@ -208,7 +205,7 @@ public class G {
         } else {
             sizes = (long) dataFs.getFreeBlocks() * (long) dataFs.getBlockSize();
         }
-        return sizes ;
+        return sizes;
     }
 
 
@@ -227,7 +224,7 @@ public class G {
      * 判断sd卡是否可用
      * return true 可用  false 不可用
      */
-    public static boolean isSDCardEnable(){
+    public static boolean isSDCardEnable() {
         return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
     }
 
@@ -236,9 +233,9 @@ public class G {
      *
      * @return SD卡剩余空间
      */
-    public static long getSdkFreeSpace(){
-        try{
-            if(!isSDCardEnable()){
+    public static long getSdkFreeSpace() {
+        try {
+            if (!isSDCardEnable()) {
                 return 0;
             }//获取SDCard根目录
             File path = Environment.getExternalStorageDirectory();
@@ -253,7 +250,7 @@ public class G {
             }
 
             return availableBlocks * blockSize;
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
             return 0;
         }
@@ -263,18 +260,19 @@ public class G {
     /**
      * 判断文件空间大小
      */
-    public static void showInstallToast(Context context, File file){
-        try{
+    public static void showInstallToast(Context context, File file) {
+        try {
             if (0 <= file.length() && (
                     file.length() > getFreeSpaceB() / 2
                             && file.length() > getSdkFreeSpace() / 2
             )) {
                 DialogStorageLow.showDialog(null);
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
+
     /**
      * 获取手机屏幕密度
      */
@@ -326,7 +324,7 @@ public class G {
      */
     public static int getTitleBarHeight(AppCompatActivity mActivity) {
         ActionBar actionBar = mActivity.getSupportActionBar();
-        if(actionBar == null){
+        if (actionBar == null) {
             return 0;
         }
         int titleBarHeight = actionBar.getHeight();