From 76abafe1cc34930828f75cfb384f99e156c8dfa5 Mon Sep 17 00:00:00 2001 From: max Date: Fri, 26 Apr 2024 17:02:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=80=81=E7=A4=BC?= =?UTF-8?q?=E9=BA=A6=E4=BD=8D=E5=8A=A8=E7=94=BB=E9=94=99=E4=BD=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chwl/app/avroom/widget/GiftV2View.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/chwl/app/avroom/widget/GiftV2View.java b/app/src/main/java/com/chwl/app/avroom/widget/GiftV2View.java index dcbd5f098..e21864a78 100644 --- a/app/src/main/java/com/chwl/app/avroom/widget/GiftV2View.java +++ b/app/src/main/java/com/chwl/app/avroom/widget/GiftV2View.java @@ -92,6 +92,8 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect private Keyframe[] keyTrans; private SvgaObjectPool mMagicViewPool; + private boolean isRTL = false; + public GiftV2View(Context context) { this(context, null); } @@ -107,6 +109,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect private void init(Context context) { this.context = context; + isRTL = UiUtils.INSTANCE.isRtl(context); mSVGAParser = new SVGAParser(context); mSVGAVideoEntityMap = new HashMap<>(20); LayoutInflater.from(getContext()).inflate(R.layout.layout_gift_v2_view, this, true); @@ -250,7 +253,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect LogUtil.print("gift micViewPoint is null"); continue; } - Point senderPoint = micViewPoint.get(senderPosition); Point receivePoint = micViewPoint.get(receivePosition); //设置动画结束的位置 @@ -652,7 +654,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect Keyframe keyTransX3 = (Keyframe.ofFloat(0.5f, center.x - senderPoint.x - giftWidth / 2)); Keyframe keyTransX4 = (Keyframe.ofFloat(0.8f, center.x - senderPoint.x - giftWidth / 2)); Keyframe keyTransX5 = (Keyframe.ofFloat(1f, receivePoint.x - senderPoint.x)); - if (UiUtils.INSTANCE.isRtl(getContext())) { + if (isRTL) { keyTransX3 = (Keyframe.ofFloat(0.5f, senderPoint.x - center.x + giftWidth / 2)); keyTransX4 = (Keyframe.ofFloat(0.8f, senderPoint.x - center.x + giftWidth / 2)); keyTransX5 = (Keyframe.ofFloat(1f, senderPoint.x - receivePoint.x)); @@ -848,10 +850,12 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect private static class SvgaObjectPool extends ObjectPool { private WeakReference mReference; + private boolean isRTL = false; SvgaObjectPool(GiftV2View giftV2View) { super(); mReference = new WeakReference<>(giftV2View); + isRTL = UiUtils.INSTANCE.isRtl(giftV2View.getContext()); } private SVGAImageView cleanView(SVGAImageView imageView) { @@ -881,7 +885,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect SVGAImageView imageView = cleanView(super.borrowObject()); LayoutParams params = new LayoutParams(parent.giftWidth, parent.giftHeight); imageView.setLayoutParams(params); - params.setMarginStart(senderPoint.x); + if (isRTL) { + params.rightMargin = senderPoint.x; + }else{ + params.leftMargin = senderPoint.x; + } params.topMargin = senderPoint.y; imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); if (parent.indexOfChild(imageView) == -1) @@ -902,7 +910,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect SVGAImageView imageView = cleanView(super.borrowObject()); LayoutParams params = new LayoutParams(parent.giftWidth, parent.giftHeight); imageView.setLayoutParams(params); - params.setMarginStart(senderPoint.x); + if (isRTL) { + params.rightMargin = senderPoint.x; + }else{ + params.leftMargin = senderPoint.x; + } params.topMargin = senderPoint.y; imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setScaleX(1.5F);