Fixed SonarLint problems
* Removed alphaRelativeDuration as there is no use for it
This commit is contained in:
parent
345ba74d58
commit
f8c52c4dac
|
@ -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)
|
||||
|
|
|
@ -600,22 +600,24 @@ public final class Player implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public Boolean shouldFastForward(@NonNull final DisplayPortion portion) {
|
||||
public Optional<Boolean> 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;
|
||||
}
|
||||
|
|
|
@ -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<Boolean>
|
||||
fun seek(forward: Boolean)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue