From b21bd5a01ec48d0de0ac8301a5470b3ab61dd259 Mon Sep 17 00:00:00 2001 From: Rashad Sookram Date: Fri, 8 Apr 2022 17:34:50 -0400 Subject: [PATCH] Ensure PiP view is animated to its final position. --- .../components/webrtc/WebRtcCallView.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallView.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallView.java index 6f209b3bc0..c97f6c972c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/WebRtcCallView.java @@ -782,15 +782,23 @@ public class WebRtcCallView extends ConstraintLayout { dimens = new Point(ViewUtil.dpToPx(90), ViewUtil.dpToPx(160)); } - ResizeAnimation animation = new ResizeAnimation(smallLocalRenderFrame, dimens.x, dimens.y); - animation.setDuration(PIP_RESIZE_DURATION); - animation.setAnimationListener(new SimpleAnimationListener() { + SimpleAnimationListener animationListener = new SimpleAnimationListener() { @Override public void onAnimationEnd(Animation animation) { pictureInPictureGestureHelper.enableCorners(); pictureInPictureGestureHelper.adjustPip(); } - }); + }; + + ViewGroup.LayoutParams layoutParams = smallLocalRenderFrame.getLayoutParams(); + if (layoutParams.width == dimens.x && layoutParams.height == dimens.y) { + animationListener.onAnimationEnd(null); + return; + } + + ResizeAnimation animation = new ResizeAnimation(smallLocalRenderFrame, dimens.x, dimens.y); + animation.setDuration(PIP_RESIZE_DURATION); + animation.setAnimationListener(animationListener); smallLocalRenderFrame.startAnimation(animation); }