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