From 0abd2bcba689a1d2535777344ec009dcceec9923 Mon Sep 17 00:00:00 2001 From: AioiLight Date: Sun, 5 Apr 2020 00:47:45 +0900 Subject: [PATCH] Clean up code 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> --- .../newpipe/player/MainVideoPlayer.java | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index 4148acd1b..c764b0753 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -1125,24 +1125,6 @@ public final class MainVideoPlayer extends AppCompatActivity }; } - 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 /////////////////////////////////////////////////////////////////////////// @@ -1263,10 +1245,10 @@ public final class MainVideoPlayer extends AppCompatActivity 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; } @@ -1358,6 +1340,22 @@ public final class MainVideoPlayer extends AppCompatActivity 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");