Skip to content

Commit

Permalink
made formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
harshlele authored and Stypox committed Apr 10, 2020
1 parent 9487b53 commit fe18896
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1217,9 +1217,8 @@ public boolean onTouch(final View v, final MotionEvent event) {
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;
}
Expand Down Expand Up @@ -1277,27 +1276,22 @@ private boolean handleMultiDrag(final MotionEvent event) {
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;

Expand Down

0 comments on commit fe18896

Please sign in to comment.