Browse Source

修复vip通道无法跳转的bug;
尝试修复bugly上面的bug

zengjiebin 7 years ago
parent
commit
cd8441b531

+ 5 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/Applications.java

@@ -505,4 +505,9 @@ public class Applications implements IDownload, IGameGroup, Serializable {
         }
         return port_type_name + "·" + package_type_name;
     }
+
+    //有 game_discount_id 就可以跳转vip通过进行3折充值
+    public boolean hasGameDiscountId() {
+        return game_discount_id > 0;
+    }
 }

+ 1 - 5
app/src/main/java/com/sheep/gamegroup/module/game/activity/ActGameGroupOrGameDetail.java

@@ -268,11 +268,7 @@ public class ActGameGroupOrGameDetail extends BaseActivity {
         //下载按钮
         CommonUtil.getInstance().palyGameDetailBtnValue(false, gameEntity, gc_game_app_detail_bt2, 0);
         fgtGameDetail.loadData(gameEntity);
-        if (gameEntity.getApp().getGame_discount_id() == 0) {
-            gc_game_app_detail_bt3.setVisibility(View.GONE);
-        } else {
-            gc_game_app_detail_bt3.setVisibility(View.VISIBLE);
-        }
+        ViewUtil.setVisibility(gc_game_app_detail_bt3, gameEntity.getApp().hasGameDiscountId());
     }
     //更新评分
     public void updateScore(float score) {

+ 1 - 0
app/src/main/java/com/sheep/gamegroup/module/game/adapter/AdpGameGroupGameCompare.java

@@ -35,6 +35,7 @@ public class AdpGameGroupGameCompare extends BaseQuickAdapter<Applications, Base
         View item_gggc_line = helper.itemView.findViewById(R.id.item_gggc_line);
 
         item_gggc_vip_tv.setOnClickListener(view -> Jump2View.getInstance().gotoGameVipRecharge(item));
+        ViewUtil.setVisibility(item_gggc_vip_tv, item.hasGameDiscountId());
         ViewUtil.setText(item_gggc_name_tv, item.getGameFrom());
         ViewUtil.setText(item_gggc_info_tv, item.getSimpleInfo());
         ViewUtil.setText(item_gggc_score_tv, NumberFormatUtils.retain1(item.getScore())+"分");

+ 102 - 60
app/src/main/java/com/sheep/gamegroup/util/GlideImageLoader.java

@@ -37,23 +37,35 @@ import rx.functions.Action1;
 public class GlideImageLoader {
 
     public static void setBlur(ImageView imageView, Object url) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().transform(new BlurTransformation()))
                 .into(imageView);
     }
     public static void setImage(ImageView imageView, Object url) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .into(imageView);
     }
     public static void setImage(ImageView imageView, Object url, int id) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().placeholder(id))
                 .into(imageView);
     }
     public static void setImageDisHardConfig(ImageView imageView, Object url) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().disallowHardwareConfig())
@@ -61,6 +73,9 @@ public class GlideImageLoader {
     }
 
     public static void centerImage(ImageView imageView, Object url, int id) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().centerCrop().placeholder(id))
@@ -68,6 +83,9 @@ public class GlideImageLoader {
     }
 
     public static void centerImage(ImageView imageView, Object path) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(path)
                 .apply(new RequestOptions().centerCrop().placeholder(R.drawable.loading_01))
@@ -75,6 +93,9 @@ public class GlideImageLoader {
     }
 
     public static void circleImage(ImageView imageView, Object url, int id) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().circleCrop().placeholder(id))
@@ -82,6 +103,9 @@ public class GlideImageLoader {
     }
 
     public static void circleImage(ImageView imageView, Object url) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().circleCrop().placeholder(R.drawable.loading_01))
@@ -89,6 +113,9 @@ public class GlideImageLoader {
     }
 
     public static void roundedCornersImage(ImageView imageView, Object url, int radius, int id) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().transform(new RoundedCornersTransformation(radius, 0)).placeholder(id))
@@ -96,18 +123,27 @@ public class GlideImageLoader {
     }
 
     public static void roundedCornersImage(ImageView imageView, Object url, int radius) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().transform(new RoundedCornersTransformation(radius, 0)).placeholder(R.drawable.loading_01))
                 .into(imageView);
     }
     public static void roundedCornersImage1(ImageView imageView, Object url, int radius) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().centerCrop().transform(new RoundedCorners(radius)))
                 .into(imageView);
     }
     public static void setGameImage(ImageView imageView, String url) {
+        if(imageView == null){
+            return;
+        }
         if(url.endsWith(".gif")){//gif图片不做任务处理
             Glide.with(SheepApp.getInstance())
                     .load(url)
@@ -121,6 +157,9 @@ public class GlideImageLoader {
         }
     }
     public static void setGameImage(ImageView imageView, String url, int radius) {
+        if(imageView == null){
+            return;
+        }
         Glide.with(SheepApp.getInstance())
                 .load(url)
                 .apply(new RequestOptions().centerCrop().transform(new RoundedCorners(radius)).placeholder(R.drawable.loading_01))
@@ -176,23 +215,20 @@ public class GlideImageLoader {
 
 
     public static void downloadAndSetImage(final ImageView imageView, final String link, final int w) {
-        downLoadImage(String.format(Locale.CHINA, "%d", link.hashCode()), link, new Action1<File>() {
-            @Override
-            public void call(File file) {
-                if(imageView != null) {
-                    if (file == null)
-                        Glide.with(SheepApp.getInstance())
-                                .load(link)
-                                .apply(new RequestOptions().override(w, w))
-                                .into(imageView);
-                    else
-                        Glide.with(SheepApp.getInstance())
-                                .load(file)
-                                .apply(new RequestOptions().override(w, w))
-                                .into(imageView);
-                }
-
+        downLoadImage(String.format(Locale.CHINA, "%d", link.hashCode()), link, file -> {
+            if(imageView != null) {
+                if (file == null)
+                    Glide.with(SheepApp.getInstance())
+                            .load(link)
+                            .apply(new RequestOptions().override(w, w))
+                            .into(imageView);
+                else
+                    Glide.with(SheepApp.getInstance())
+                            .load(file)
+                            .apply(new RequestOptions().override(w, w))
+                            .into(imageView);
             }
+
         });
 
     }
@@ -230,46 +266,52 @@ public class GlideImageLoader {
 
     /**
      * 设置头像
-     * @param iconImgIv
+     * @param imageView
      * @param avatar
      */
-    public static void setAvatar(ImageView iconImgIv, String avatar) {
+    public static void setAvatar(ImageView imageView, String avatar) {
+        if(imageView == null){
+            return;
+        }
         if(TextUtils.isEmpty(avatar)){
             Glide.with(SheepApp.getInstance())
                     .load(R.drawable.avatar)
-                    .into(iconImgIv);
+                    .into(imageView);
         } else {
             Glide.with(SheepApp.getInstance())
                     .load(avatar)
                     .apply(new RequestOptions().circleCrop().placeholder(R.drawable.avatar))
-                    .into(iconImgIv);
+                    .into(imageView);
         }
     }
     /**
      * 设置头像有外面的圆环
-     * @param iconImgIv
+     * @param imageView
      * @param avatar
      */
-    public static void setAvatar(ImageView iconImgIv, String avatar, int color) {
-        Object tag = iconImgIv.getTag(R.drawable.avatar);
+    public static void setAvatar(ImageView imageView, String avatar, int color) {
+        if(imageView == null){
+            return;
+        }
+        Object tag = imageView.getTag(R.drawable.avatar);
         if(TextUtils.isEmpty(avatar)){
             if(tag instanceof String && tag.toString().isEmpty()){//防止重复加载
                 return;
             }
-            iconImgIv.setTag(R.drawable.avatar, "");
+            imageView.setTag(R.drawable.avatar, "");
             Glide.with(SheepApp.getInstance())
                     .load(R.drawable.avatar)
-                    .apply(new RequestOptions().override(iconImgIv.getMeasuredWidth()).transform(new GlideCircleTransformWithBorder(color)))
-                    .into(iconImgIv);
+                    .apply(new RequestOptions().override(imageView.getMeasuredWidth()).transform(new GlideCircleTransformWithBorder(color)))
+                    .into(imageView);
         } else {
             if(tag instanceof String && tag.toString().equals(avatar)){//防止重复加载
                 return;
             }
-            iconImgIv.setTag(R.drawable.avatar, avatar);
+            imageView.setTag(R.drawable.avatar, avatar);
             Glide.with(SheepApp.getInstance())
                     .load(avatar)
                     .apply(new RequestOptions().transform(new GlideCircleTransformWithBorder(color)).placeholder(R.drawable.avatar))
-                    .into(iconImgIv);
+                    .into(imageView);
         }
     }
 
@@ -282,26 +324,26 @@ public class GlideImageLoader {
      * @param radius
      */
     public static void downloadAndRoundedImage(String name, final String link, final ImageView imageView, final int width, final int radius) {
-        GlideImageLoader.downLoadImage(name, link, new Action1<File>() {
-            @Override
-            public void call(File file) {
-                if(file == null){
-                    return;
-                }
-                BitmapFactory.Options options = FileUtil.getImageOptions(file);
-                int w = options.outWidth;
-                int h = options.outHeight;
+        if(imageView == null){
+            return;
+        }
+        GlideImageLoader.downLoadImage(name, link, file -> {
+            if(file == null){
+                return;
+            }
+            BitmapFactory.Options options = FileUtil.getImageOptions(file);
+            int w = options.outWidth;
+            int h = options.outHeight;
 //                int w = width;
 //                int h = width * options.outHeight / options.outWidth;
-                if(Math.abs(w-h) < Math.min(w, h)){
-                    setImage(imageView, link);
-                    return;
-                }
-                Glide.with(SheepApp.getInstance())
-                        .load(file)
-                        .apply(new RequestOptions().override(w, h).fitCenter().transform(new RoundedCorners(radius)))
-                        .into(imageView);
+            if(Math.abs(w-h) < Math.min(w, h)){
+                setImage(imageView, link);
+                return;
             }
+            Glide.with(SheepApp.getInstance())
+                    .load(file)
+                    .apply(new RequestOptions().override(w, h).fitCenter().transform(new RoundedCorners(radius)))
+                    .into(imageView);
         });
     }
     /**
@@ -312,23 +354,23 @@ public class GlideImageLoader {
      * @param radius
      */
     public static void downloadAndRoundedImage(String name, String link, final ImageView imageView, final int radius, final RequestListener<Drawable> listener) {
-        GlideImageLoader.downLoadImage(name, link, new Action1<File>() {
-            @Override
-            public void call(File file) {
-                if(file == null){
-                    return;
-                }
-                BitmapFactory.Options options = FileUtil.getImageOptions(file);
-                int w = options.outWidth;
-                int h = options.outHeight;
+        if(imageView == null){
+            return;
+        }
+        GlideImageLoader.downLoadImage(name, link, file -> {
+            if(file == null){
+                return;
+            }
+            BitmapFactory.Options options = FileUtil.getImageOptions(file);
+            int w = options.outWidth;
+            int h = options.outHeight;
 //                int w = width;
 //                int h = width * options.outHeight / options.outWidth;
-                Glide.with(SheepApp.getInstance())
-                        .load(file)
-                        .listener(listener)
-                        .apply(new RequestOptions().override(w, h).transform(new RoundedCorners(radius)))
-                        .into(imageView);
-            }
+            Glide.with(SheepApp.getInstance())
+                    .load(file)
+                    .listener(listener)
+                    .apply(new RequestOptions().override(w, h).transform(new RoundedCorners(radius)))
+                    .into(imageView);
         });
     }
 }

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

@@ -465,6 +465,9 @@ public class ViewUtil {
      * @param textView
      */
     public static void setDefaultText(TextView textView) {
+        if(textView == null){
+            return;
+        }
         String text = textView.getText().toString();
         int length = TextUtils.isEmpty(text) ? Math.abs(new Random().nextInt(7)) : text.length();
         StringBuilder stringBuilder = new StringBuilder();

+ 6 - 13
app/src/main/java/com/sheep/jiuyan/samllsheep/base/BaseFragment.java

@@ -146,19 +146,12 @@ public abstract class BaseFragment extends RxFragment {
      * @return
      */
     public <T extends View> T findViewById(@IdRes int id) {
-        return (T) getView().findViewById(id);
-    }
-
-    /**
-     * 万能的找View类
-     *
-     * @param id
-     * @param tClass
-     * @param <T>
-     * @return
-     */
-    public <T extends View> T findViewById(@IdRes int id, Class<T> tClass) {
-        return (T) getView().findViewById(id);
+        try {
+            return (T) getView().findViewById(id);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
     }
 
     @Override