fix:修复送礼麦位动画错位问题

This commit is contained in:
max
2024-04-26 17:02:56 +08:00
parent 6256151928
commit 76abafe1cc

View File

@@ -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<SVGAImageView> {
private WeakReference<GiftV2View> 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);