From c370c874126ed2eda3348ae060d9905a4a762689 Mon Sep 17 00:00:00 2001 From: HuanChengFly <609486518@qq.com> Date: Thu, 16 Jul 2020 16:19:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A5=BC=E4=B8=AD?= =?UTF-8?q?=E6=A5=BC=E5=A4=A7=E5=9B=BE=E5=8A=A0=E8=BD=BD=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../post/adapters/RecyclerFloorAdapter.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/adapters/RecyclerFloorAdapter.java b/app/src/main/java/com/huanchengfly/tieba/post/adapters/RecyclerFloorAdapter.java index 68fcd381..75f02d91 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/adapters/RecyclerFloorAdapter.java +++ b/app/src/main/java/com/huanchengfly/tieba/post/adapters/RecyclerFloorAdapter.java @@ -10,6 +10,7 @@ import android.text.format.DateUtils; import android.text.method.LinkMovementMethod; import android.util.DisplayMetrics; import android.util.Log; +import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -257,22 +258,23 @@ public class RecyclerFloorAdapter extends CommonBaseAdapter= this.maxWidth) { - heightFloat = heightFloat * (this.maxWidth / widthFloat); + widthFloat = Float.parseFloat(strings[0]); + heightFloat = Float.parseFloat(strings[1]); + heightFloat *= this.maxWidth / widthFloat; widthFloat = this.maxWidth; + } else { + float width = Float.parseFloat(contentBean.getWidth()); + widthFloat = this.maxWidth; + heightFloat = Float.parseFloat(contentBean.getHeight()); + heightFloat *= widthFloat / width; } int width = Math.round(widthFloat); int height = Math.round(heightFloat); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height); + layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.setMargins(0, 8, 0, 8); return layoutParams; } @@ -370,8 +372,8 @@ public class RecyclerFloorAdapter extends CommonBaseAdapter photoViewBeans = new ArrayList<>(); - photoViewBeans.add(new PhotoViewBean(ImageUtil.getNonNullString(contentBean.getCdnSrc(), contentBean.getCdnSrcActive(), contentBean.getBigCdnSrc(), contentBean.getOriginSrc()), - ImageUtil.getNonNullString(contentBean.getOriginSrc(), contentBean.getBigCdnSrc(), contentBean.getCdnSrcActive(), contentBean.getCdnSrc()), + photoViewBeans.add(new PhotoViewBean(ImageUtil.getNonNullString(contentBean.getSrc(), contentBean.getOriginSrc()), + ImageUtil.getNonNullString(contentBean.getOriginSrc(), contentBean.getSrc()), "1".equals(contentBean.getIsLongPic()))); ImageUtil.initImageView(imageView, photoViewBeans, 0); views.add(imageView);