From fe1889653e98b7fb55d24b03f9d4903e26b82278 Mon Sep 17 00:00:00 2001 From: Harshal Lele Date: Sun, 8 Mar 2020 12:10:06 +0530 Subject: [PATCH] made formatting changes --- .../newpipe/player/PopupVideoPlayer.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java index 0cb1fe6c9..e46aa94d6 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -1217,9 +1217,8 @@ public final class PopupVideoPlayer extends Service { initSecPointerX = event.getX(1); initSecPointerY = event.getY(1); //record distance between fingers - float xDiff = event.getX(0) - event.getX(1); - float yDiff = event.getY(0) - event.getY(1); - initPointerDistance = Math.sqrt(xDiff * xDiff + yDiff * yDiff); + initPointerDistance = Math.hypot(event.getX(0) - event.getX(1), + event.getY(0) - event.getY(1)); isResizing = true; } @@ -1277,27 +1276,22 @@ public final class PopupVideoPlayer extends Service { int scaledTouchSlop = ViewConfiguration.get(PopupVideoPlayer.this).getScaledTouchSlop(); if(firstPointerMoveX > scaledTouchSlop ||firstPointerMoveY > scaledTouchSlop || - secPointerMoveX > scaledTouchSlop || secPointerMoveY > scaledTouchSlop){ + secPointerMoveX > scaledTouchSlop || secPointerMoveY > scaledTouchSlop) { double newWidth = popupWidth; //calculate current distance between the pointers - float currentXDiff = event.getX(0) - event.getX(1); - float currentYDiff = event.getY(0) - event.getY(1); - double currentPointerDistance = Math.sqrt(currentXDiff * currentXDiff + currentYDiff * currentYDiff); + double currentPointerDistance = Math.hypot(event.getX(0) - event.getX(1), + event.getY(0) - event.getY(1)); //scale popup width - double scale = 1 + (currentPointerDistance - initPointerDistance)/ initPointerDistance; + double scale = currentPointerDistance / initPointerDistance; newWidth = (popupWidth * scale); //change co-ordinates of popup so the center stays at the same position - if(currentPointerDistance > initPointerDistance){ - popupLayoutParams.x -= (newWidth - popupWidth)/2; - } - else{ - popupLayoutParams.x += (popupWidth - newWidth)/2; - } + popupLayoutParams.x += (popupWidth - newWidth)/2; + initPointerDistance = currentPointerDistance;