Skip to content

Commit f8c52c4

Browse files
committed
Fixed SonarLint problems
* Removed alphaRelativeDuration as there is no use for it
1 parent 345ba74 commit f8c52c4

3 files changed

Lines changed: 14 additions & 15 deletions

File tree

app/src/main/java/org/schabi/newpipe/ktx/View.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,8 @@ fun View.animate(
7676
animate().setListener(null).cancel()
7777
isVisible = true
7878

79-
val alphaRelativeDuration = if (enterOrExit && alpha < 1.0f) {
80-
(duration * (1 - alpha)).toLong()
81-
} else {
82-
(duration * alpha).toLong()
83-
}
84-
8579
when (animationType) {
86-
AnimationType.ALPHA -> animateAlpha(enterOrExit, alphaRelativeDuration, delay, execOnEnd)
80+
AnimationType.ALPHA -> animateAlpha(enterOrExit, duration, delay, execOnEnd)
8781
AnimationType.SCALE_AND_ALPHA -> animateScaleAndAlpha(enterOrExit, duration, delay, execOnEnd)
8882
AnimationType.LIGHT_SCALE_AND_ALPHA -> animateLightScaleAndAlpha(enterOrExit, duration, delay, execOnEnd)
8983
AnimationType.SLIDE_AND_ALPHA -> animateSlideAndAlpha(enterOrExit, duration, delay, execOnEnd)

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,22 +600,24 @@ public void onDoubleTapEnd() {
600600
}
601601

602602
@Override
603-
public Boolean shouldFastForward(@NonNull final DisplayPortion portion) {
603+
public Optional<Boolean> shouldFastForward(
604+
@NonNull final DisplayPortion portion
605+
) {
604606
// Null indicates an invalid area or condition e.g. the middle portion
605607
// or video start or end was reached during double tap seeking
606608
if (invalidSeekConditions()) {
607609
playerGestureListener.endMultiDoubleTap();
608-
return null;
610+
return Optional.empty();
609611
}
610612
if (portion == DisplayPortion.LEFT
611613
// Small puffer to eliminate infinite rewind seeking
612614
&& simpleExoPlayer.getCurrentPosition() > 500L) {
613-
return false;
615+
return Optional.of(false);
614616
} else if (portion == DisplayPortion.RIGHT) {
615-
return true;
617+
return Optional.of(true);
616618
}
617619
/* portion == DisplayPortion.MIDDLE */
618-
return null;
620+
return Optional.empty();
619621
}
620622

621623
@Override
@@ -630,7 +632,8 @@ public void seek(final boolean forward) {
630632

631633
private boolean invalidSeekConditions() {
632634
return exoPlayerIsNull()
633-
|| simpleExoPlayer.getPlaybackState() == SimpleExoPlayer.STATE_ENDED
635+
|| simpleExoPlayer.getPlaybackState()
636+
== com.google.android.exoplayer2.Player.STATE_ENDED
634637
|| simpleExoPlayer.getCurrentPosition() >= simpleExoPlayer.getDuration()
635638
|| currentState == STATE_COMPLETED;
636639
}

app/src/main/java/org/schabi/newpipe/views/player/PlayerFastSeekOverlay.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.schabi.newpipe.MainActivity
1313
import org.schabi.newpipe.R
1414
import org.schabi.newpipe.player.event.DisplayPortion
1515
import org.schabi.newpipe.player.event.DoubleTapListener
16+
import java.util.Optional
1617

1718
class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
1819
ConstraintLayout(context, attrs), DoubleTapListener {
@@ -62,7 +63,8 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
6263
}
6364

6465
override fun onDoubleTapProgressDown(portion: DisplayPortion) {
65-
val shouldForward: Boolean = performListener?.shouldFastForward(portion) ?: return
66+
val shouldForward: Boolean =
67+
performListener?.shouldFastForward(portion)?.orElse(null) ?: return
6668

6769
if (DEBUG)
6870
Log.d(
@@ -123,7 +125,7 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
123125
interface PerformListener {
124126
fun onDoubleTap()
125127
fun onDoubleTapEnd()
126-
fun shouldFastForward(portion: DisplayPortion): Boolean?
128+
fun shouldFastForward(portion: DisplayPortion): Optional<Boolean>
127129
fun seek(forward: Boolean)
128130
}
129131

0 commit comments

Comments
 (0)