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

修复二维码图片显示的空白过多的bug

zengjiebin лет назад: 7
Родитель
Сommit
dd15aac8d1

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/module/game/model/GamePortTypes.java

@@ -78,7 +78,7 @@ public class GamePortTypes {
     public GameListType toGameListType() {
         GameListType gameListType = new GameListType();
         gameListType.setPort_type(id);
-        gameListType.setTitle(name);
+        gameListType.setTitle(alias);
         return gameListType;
     }
 }

+ 13 - 23
app/src/main/java/com/sheep/gamegroup/util/GlideImageLoader.java

@@ -134,26 +134,7 @@ public class GlideImageLoader {
      * @param w
      */
     public static void saveAndSetRqImage(final ImageView imageView, String link, int w) {
-        String fileName = String.format(Locale.CHINA, "%d.png", link.hashCode());
-        File file = new File(ClassFileHelper.DIR, fileName);
-        if(!file.exists()){
-            Bitmap mBitmap = CodeUtils.createImage(link, w, w, null);
-            if(mBitmap != null) {
-                ViewUtil.saveImage(mBitmap, ClassFileHelper.DIR, fileName);
-                if(imageView != null)
-                    Glide.with(SheepApp.getInstance())
-                            .load(file)
-                            .apply(new RequestOptions().override(w, w))
-                            .into(imageView);
-            }
-        }
-        if(file.exists()){
-            if(imageView != null)
-                Glide.with(SheepApp.getInstance())
-                        .load(file)
-                        .apply(new RequestOptions().override(w, w))
-                        .into(imageView);
-        }
+        saveAndSetRqImage(imageView, link, w, new RequestOptions().override(w, w));
     }
     /**
      * 设置二维码图片
@@ -162,7 +143,16 @@ public class GlideImageLoader {
      * @param w
      */
     public static void saveAndSetRqImageDisHardConfig(final ImageView imageView, String link, int w) {
-        String fileName = String.format(Locale.CHINA, "%d.png", link.hashCode());
+        saveAndSetRqImage(imageView, link, w, new RequestOptions().disallowHardwareConfig().override(w, w));
+    }
+    /**
+     * 设置二维码图片
+     * @param imageView
+     * @param link
+     * @param w
+     */
+    public static void saveAndSetRqImage(final ImageView imageView, String link, int w, RequestOptions requestOptions) {
+        String fileName = String.format(Locale.CHINA, "%d_%d_%d.png", link.hashCode(), w, w);
         File file = new File(ClassFileHelper.DIR, fileName);
         if(!file.exists()){
             Bitmap mBitmap = CodeUtils.createImage(link, w, w, null);
@@ -171,7 +161,7 @@ public class GlideImageLoader {
                 if(imageView != null)
                     Glide.with(SheepApp.getInstance())
                             .load(file)
-                            .apply(new RequestOptions().disallowHardwareConfig().override(w, w))
+                            .apply(requestOptions)
                             .into(imageView);
             }
         }
@@ -179,7 +169,7 @@ public class GlideImageLoader {
             if(imageView != null)
                 Glide.with(SheepApp.getInstance())
                         .load(file)
-                        .apply(new RequestOptions().disallowHardwareConfig().override(w, w))
+                        .apply(requestOptions)
                         .into(imageView);
         }
     }

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActInvitation.java

@@ -345,7 +345,7 @@ public class ActInvitation extends BaseUMActivity {
                     float radius = 4 / 216F;
                     float topRadius = 2 / 216F;
                     float logoRadius = rqRadius * 16 / 68;
-                    GlideImageLoader.saveAndSetRqImageDisHardConfig(image_bottom, item.getLink(), (int) (imgWidth * rqRadius));
+                    GlideImageLoader.saveAndSetRqImage(image_bottom, item.getLink(), 400, new RequestOptions().disallowHardwareConfig().override((int) (imgWidth * rqRadius)));
                     //重新设置logo的宽高
                     ViewGroup.LayoutParams layoutParams = image_logo.getLayoutParams();
                     layoutParams.width = (int) (imgWidth * logoRadius);