Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
Follow Checkstyle

Move to PlayerGestureListener from VideoPlayerImpl

Update app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java

Co-authored-by: wb9688 <46277131+wb9688@users.noreply.github.com>
  • Loading branch information
AioiLight and wb9688 committed May 9, 2020
1 parent 562754c commit 0abd2bc
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1125,24 +1125,6 @@ public void onStartDrag(final PlayQueueItemHolder viewHolder) {
};
}

private int getNavigationBarHeight()
{
int resId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
if (resId > 0) {
return getResources().getDimensionPixelSize(resId);
}
return 0;
}

private int getStatusBarHeight()
{
int resId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resId > 0) {
return getResources().getDimensionPixelSize(resId);
}
return 0;
}

///////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1263,10 +1245,10 @@ public boolean onScroll(final MotionEvent initialEvent, final MotionEvent moving
return false;
}

final boolean isTouchingStatusBar = initialEvent.getY() < playerImpl.getStatusBarHeight();
final boolean isTouchingNavigationBar = initialEvent.getY() > playerImpl.getRootView().getHeight() - playerImpl.getNavigationBarHeight();
if (isTouchingStatusBar || isTouchingNavigationBar)
{
final boolean isTouchingStatusBar = initialEvent.getY() < getStatusBarHeight();
final boolean isTouchingNavigationBar = initialEvent.getY()
> playerImpl.getRootView().getHeight() - getNavigationBarHeight();
if (isTouchingStatusBar || isTouchingNavigationBar) {
return false;
}

Expand Down Expand Up @@ -1358,6 +1340,22 @@ public boolean onScroll(final MotionEvent initialEvent, final MotionEvent moving
return true;
}

private int getNavigationBarHeight() {
int resId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
if (resId > 0) {
return getResources().getDimensionPixelSize(resId);
}
return 0;
}

private int getStatusBarHeight() {
int resId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resId > 0) {
return getResources().getDimensionPixelSize(resId);
}
return 0;
}

private void onScrollEnd() {
if (DEBUG) {
Log.d(TAG, "onScrollEnd() called");
Expand Down

0 comments on commit 0abd2bc

Please sign in to comment.