diff --git a/app/src/main/java/org/schabi/newpipe/ktx/View.kt b/app/src/main/java/org/schabi/newpipe/ktx/View.kt index ae1b4388c..8dcc9d85c 100644 --- a/app/src/main/java/org/schabi/newpipe/ktx/View.kt +++ b/app/src/main/java/org/schabi/newpipe/ktx/View.kt @@ -76,14 +76,8 @@ fun View.animate( animate().setListener(null).cancel() isVisible = true - val alphaRelativeDuration = if (enterOrExit && alpha < 1.0f) { - (duration * (1 - alpha)).toLong() - } else { - (duration * alpha).toLong() - } - when (animationType) { - AnimationType.ALPHA -> animateAlpha(enterOrExit, alphaRelativeDuration, delay, execOnEnd) + AnimationType.ALPHA -> animateAlpha(enterOrExit, duration, delay, execOnEnd) AnimationType.SCALE_AND_ALPHA -> animateScaleAndAlpha(enterOrExit, duration, delay, execOnEnd) AnimationType.LIGHT_SCALE_AND_ALPHA -> animateLightScaleAndAlpha(enterOrExit, duration, delay, execOnEnd) AnimationType.SLIDE_AND_ALPHA -> animateSlideAndAlpha(enterOrExit, duration, delay, execOnEnd) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index b37dddc7b..f7ef13d7a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -600,22 +600,24 @@ public final class Player implements } @Override - public Boolean shouldFastForward(@NonNull final DisplayPortion portion) { + public Optional shouldFastForward( + @NonNull final DisplayPortion portion + ) { // Null indicates an invalid area or condition e.g. the middle portion // or video start or end was reached during double tap seeking if (invalidSeekConditions()) { playerGestureListener.endMultiDoubleTap(); - return null; + return Optional.empty(); } if (portion == DisplayPortion.LEFT // Small puffer to eliminate infinite rewind seeking && simpleExoPlayer.getCurrentPosition() > 500L) { - return false; + return Optional.of(false); } else if (portion == DisplayPortion.RIGHT) { - return true; + return Optional.of(true); } /* portion == DisplayPortion.MIDDLE */ - return null; + return Optional.empty(); } @Override @@ -630,7 +632,8 @@ public final class Player implements private boolean invalidSeekConditions() { return exoPlayerIsNull() - || simpleExoPlayer.getPlaybackState() == SimpleExoPlayer.STATE_ENDED + || simpleExoPlayer.getPlaybackState() + == com.google.android.exoplayer2.Player.STATE_ENDED || simpleExoPlayer.getCurrentPosition() >= simpleExoPlayer.getDuration() || currentState == STATE_COMPLETED; } diff --git a/app/src/main/java/org/schabi/newpipe/views/player/PlayerFastSeekOverlay.kt b/app/src/main/java/org/schabi/newpipe/views/player/PlayerFastSeekOverlay.kt index 23f56fa67..5a3eb9a4e 100644 --- a/app/src/main/java/org/schabi/newpipe/views/player/PlayerFastSeekOverlay.kt +++ b/app/src/main/java/org/schabi/newpipe/views/player/PlayerFastSeekOverlay.kt @@ -13,6 +13,7 @@ import org.schabi.newpipe.MainActivity import org.schabi.newpipe.R import org.schabi.newpipe.player.event.DisplayPortion import org.schabi.newpipe.player.event.DoubleTapListener +import java.util.Optional class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) : ConstraintLayout(context, attrs), DoubleTapListener { @@ -62,7 +63,8 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) : } override fun onDoubleTapProgressDown(portion: DisplayPortion) { - val shouldForward: Boolean = performListener?.shouldFastForward(portion) ?: return + val shouldForward: Boolean = + performListener?.shouldFastForward(portion)?.orElse(null) ?: return if (DEBUG) Log.d( @@ -123,7 +125,7 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) : interface PerformListener { fun onDoubleTap() fun onDoubleTapEnd() - fun shouldFastForward(portion: DisplayPortion): Boolean? + fun shouldFastForward(portion: DisplayPortion): Optional fun seek(forward: Boolean) }