Просмотр исходного кода

fixed 8.0 version difference feature

hanjing лет назад: 7
Родитель
Сommit
bbe65f1167

+ 34 - 25
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -311,7 +311,7 @@ public class ViewUtil {
 
     public static void dismiss(final AlertDialog dialog, int delay) {
         if (dialog != null) {
-            AbsObserver<Integer> absObserver =new AbsObserver<Integer>() {
+            AbsObserver<Integer> absObserver = new AbsObserver<Integer>() {
                 @Override
                 public void onNext(Integer integer) {
                     try {
@@ -343,7 +343,7 @@ public class ViewUtil {
     }
 
     public static void setTextSize(TextView textView, int tsType, int textSize) {
-        if(textView != null){
+        if (textView != null) {
             textView.setTextSize(tsType, textSize);
         }
     }
@@ -480,7 +480,7 @@ public class ViewUtil {
      * @param textView
      */
     public static void setDefaultText(TextView textView) {
-        if(textView == null){
+        if (textView == null) {
             return;
         }
         String text = textView.getText().toString();
@@ -530,7 +530,7 @@ public class ViewUtil {
         });
         edInvitationCode.setOnLongClickListener(view1 -> {
             CharSequence text = StringUtils.getCopyText();
-            if(!TextUtils.isEmpty(text)){
+            if (!TextUtils.isEmpty(text)) {
                 edInvitationCode.setText(text);
             }
             return false;
@@ -1282,6 +1282,7 @@ public class ViewUtil {
         }
         return dialog;
     }
+
     public static AlertDialog showUpgradeDialog(Context mContext, final DialogConfig dialogConfig) {
         String title = dialogConfig.getTitle();
         String msg = dialogConfig.getMsg();
@@ -1408,7 +1409,7 @@ public class ViewUtil {
                 .create();
         GifImageView dialog_gif = dialog_parent.findViewById(R.id.dialog_gif);
         Drawable drawable = dialog_gif.getDrawable();
-        if(drawable instanceof GifDrawable){
+        if (drawable instanceof GifDrawable) {
             ((GifDrawable) drawable).addAnimationListener(loopNumber -> {
                 try {
                     dialog.dismiss();
@@ -1428,9 +1429,10 @@ public class ViewUtil {
 
     //显示游戏对话框  点击前往或者x会向粘贴板中写入空数据
     public static void showGameDialog(Applications applications, View.OnClickListener onClickListener) {
-        Context mContext = SheepApp.getInstance();
+        if (SheepApp.getInstance().getCurrentActivity() == null) return;
+        Context mContext = SheepApp.getInstance().getCurrentActivity();
         View dialog_parent = View.inflate(SheepApp.getInstance(), R.layout.dialog_parent, null);
-        final AlertDialog dialog = new AlertDialog.Builder(mContext,R.style.AppTheme_Dialog_Alert).setView(dialog_parent).create();
+        final AlertDialog dialog = new AlertDialog.Builder(mContext, R.style.AppTheme_Dialog_Alert).setView(dialog_parent).create();
         LinearLayout dialog_center_ll = dialog_parent.findViewById(R.id.dialog_center_ll);
         TextView dialog_title = dialog_parent.findViewById(R.id.dialog_title);
         View dialog_close = dialog_parent.findViewById(R.id.dialog_close);
@@ -1456,9 +1458,9 @@ public class ViewUtil {
             dismiss(dialog, 0);
         });
 
-        if (dialog.getWindow() != null) {
-            dialog.getWindow().setType(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? WindowManager.LayoutParams.TYPE_PHONE : WindowManager.LayoutParams.TYPE_TOAST);
-        }
+//        if (dialog.getWindow() != null) {
+//            dialog.getWindow().setType(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? WindowManager.LayoutParams.TYPE_PHONE : WindowManager.LayoutParams.TYPE_TOAST);
+//        }
         try {
             dialog.show();
         } catch (Exception e) {
@@ -1466,6 +1468,7 @@ public class ViewUtil {
         }
 
     }
+
     /**
      * 通过map来设置字体颜色
      *
@@ -1739,7 +1742,7 @@ public class ViewUtil {
                                 @Override
                                 public void onNext(BaseMessage baseMessage) {
                                     ReceiveCouponsResp receiveCouponsResp = baseMessage.getData(ReceiveCouponsResp.class);
-                                    if(receiveCouponsResp != null){
+                                    if (receiveCouponsResp != null) {
                                         Jump2View.getInstance().goWeb(activity, new WebParams(receiveCouponsResp.getBuy_url(), Config.YF_SHOP_NAME).setShowTitle(false));
                                     }
                                 }
@@ -1759,6 +1762,7 @@ public class ViewUtil {
             }
         }
     }
+
     //3.4.7添加 -- 展示 元旦活动中 提示用户邀请人数到达一定数量时,获得了礼品,需要填写收件地址 对话框
     public static void showYfShopAsk(final Activity activity, String btnText, String content, Action1<AlertDialog> action1) {
         if (activity != null) {
@@ -1793,7 +1797,7 @@ public class ViewUtil {
             dialog_yf_shop_ask_btn_tv.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View v) {
-                    if(action1 != null){
+                    if (action1 != null) {
                         action1.call(dialog);
                     }
                 }
@@ -1900,7 +1904,7 @@ public class ViewUtil {
 
     public static void setImage(ImageView imageView, Object object) {
         if (imageView != null) {
-            if(object instanceof String) {
+            if (object instanceof String) {
                 String pictures = object.toString();
                 if (TextUtils.isEmpty(pictures)) {
                     imageView.setImageResource(SkinUtil.getAppIcon());
@@ -1937,13 +1941,14 @@ public class ViewUtil {
     public static void setViewWH(View view, int width, float radio) {
         LayoutParamsUtil.resetLayoutParams(view, new Lp().setWidth(width).setHeight((int) (width * radio)));
     }
+
     public static void setImageWH(ImageView view, String url, int width, int radius) {
-        if(url == null || view == null){
+        if (url == null || view == null) {
             return;
         }
-        int w = DataUtil.getAsInt(url+"_w", 0);
-        int h = DataUtil.getAsInt(url+"_h", 0);
-        if(w > 0 && h > 0) {
+        int w = DataUtil.getAsInt(url + "_w", 0);
+        int h = DataUtil.getAsInt(url + "_h", 0);
+        if (w > 0 && h > 0) {
             float radio = h * 1.0f / w;
             ViewUtil.setViewWH(view, width, radio);
         } else {
@@ -1961,8 +1966,8 @@ public class ViewUtil {
                     public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                         int w = resource.getIntrinsicWidth();
                         int h = resource.getIntrinsicHeight();
-                        DataUtil.putAsInt(url+"_w", w);
-                        DataUtil.putAsInt(url+"_h", h);
+                        DataUtil.putAsInt(url + "_w", w);
+                        DataUtil.putAsInt(url + "_h", h);
                         return false;
                     }
                 })
@@ -2021,6 +2026,7 @@ public class ViewUtil {
             }
         }
     }
+
     public static void roundedCornersImage1(ImageView imageView, String pictures, int radius) {
         if (imageView != null) {
             if (TextUtils.isEmpty(pictures)) {
@@ -2211,6 +2217,7 @@ public class ViewUtil {
             view.setVisibility(isVisible ? View.VISIBLE : View.GONE);
         }
     }
+
     public static void setVisibility(View view, int visible) {
         if (view != null) {
             view.setVisibility(visible);
@@ -2360,9 +2367,9 @@ public class ViewUtil {
         int[] pngs = {
 //        R.mipmap.share_face_to_face");
                 R.mipmap.share_wx,
-        R.mipmap.share_qq,
-        R.mipmap.share_weixin_circle,
-        R.mipmap.share_qzone,
+                R.mipmap.share_qq,
+                R.mipmap.share_weixin_circle,
+                R.mipmap.share_qzone,
 //        R.mipmap.share_copy_share_link,
         };
         final List<String> nameList = ListUtil.emptyList();
@@ -2537,13 +2544,14 @@ public class ViewUtil {
 
         return view;
     }
+
     public static void showThenHide(Activity activity, View view, boolean isShow) {
         ViewUtil.setVisibility(view, true);
         int a = -1;
         int b = 2;
         int y1 = isShow ? a : b;
         int y2 = isShow ? b : a;
-        Animation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF,0,Animation.RELATIVE_TO_SELF, 0,Animation.RELATIVE_TO_SELF, y1,Animation.RELATIVE_TO_SELF, y2);//平移动画
+        Animation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, y1, Animation.RELATIVE_TO_SELF, y2);//平移动画
         translateAnimation.setDuration(200);//动画持续的时间
         translateAnimation.setFillEnabled(true);//使其可以填充效果从而不回到原地
         translateAnimation.setFillAfter(true);//不回到起始位置
@@ -2557,7 +2565,7 @@ public class ViewUtil {
 
             @Override
             public void onAnimationEnd(Animation animation) {
-                if(isShow) {//显示几秒后消失
+                if (isShow) {//显示几秒后消失
                     ViewUtil.delay(new AbsObserver<Integer>() {
                         @Override
                         public void onNext(Integer integer) {
@@ -2569,7 +2577,7 @@ public class ViewUtil {
                 } else {
                     ViewUtil.setVisibility(view, false);
                     ViewParent viewParent = view.getParent();
-                    if(viewParent instanceof ViewGroup){
+                    if (viewParent instanceof ViewGroup) {
                         ViewGroup viewGroup = (ViewGroup) viewParent;
                         viewGroup.removeView(view);
                         viewGroup.setTag(null);
@@ -2594,6 +2602,7 @@ public class ViewUtil {
             e.printStackTrace();
         }
     }
+
     //取消注册eventBus
     public static void unregister(Object object) {
         try {

+ 7 - 5
app/src/main/java/com/sheep/jiuyan/samllsheep/SheepApp.java

@@ -45,6 +45,7 @@ import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.TextToSpeechUtil;
 import com.sheep.gamegroup.util.UMConfigUtils;
 import com.sheep.gamegroup.view.activity.GameCertificationActivity;
+import com.sheep.gamegroup.view.activity.SplashAct;
 import com.sheep.jiuyan.samllsheep.service.AutoCheckService;
 import com.sheep.jiuyan.samllsheep.service.DownloadService;
 import com.sheep.jiuyan.samllsheep.service.FloatShotScreenService;
@@ -286,7 +287,7 @@ public class SheepApp extends MultiDexApplication {
 //        CacheFactory.setCacheManager(ProxyCacheManager.class);//代理缓存模式,支持所有模式,不支持m3u8等
 
         //鸿途信达 广告 需要添加 两行代码顺序不能变
-        if(ArticleAd.showAd) {
+        if (ArticleAd.showAd) {
             PManager.getInstance().setChannel(this, 18122801);
             PManager.getInstance().onCreate(this);
         }
@@ -297,6 +298,7 @@ public class SheepApp extends MultiDexApplication {
         // 将该app注册到微信
         wxApi.registerApp(Config.WX_PAY_APP_ID);
     }
+
     private IWXAPI wxApi;
 
     public IWXAPI getWxApi() {
@@ -477,15 +479,15 @@ public class SheepApp extends MultiDexApplication {
                     Jump2View.getInstance().startShotScreenFloat(activity, false);
                 }
             }
-            if (mActivityCount == 1) { // 应用回到前台
-                CommonUtil.getInstance().checkCopyText();
-            }
         }
 
         @Override
         public void onActivityResumed(Activity activity) {
             if (activityRef != null) activityRef.clear();
             activityRef = new WeakReference<>(activity);
+            if (getCurrentActivity() != null && !(getCurrentActivity() instanceof SplashAct)) { // 应用回到前台
+                CommonUtil.getInstance().checkCopyText();
+            }
         }
 
         @Override
@@ -585,7 +587,7 @@ public class SheepApp extends MultiDexApplication {
         MultiDex.install(this);
         PluginManager.getInstance(base).init();//插件化框架
         //鸿途信达 广告 需要添加
-        if(ArticleAd.showAd) {
+        if (ArticleAd.showAd) {
             PManager.getInstance().attachBaseContext(base);
         }
     }