@@ -4,6 +4,7 @@ import android.content.Context
44import android.util.AttributeSet
55import android.util.Log
66import android.view.LayoutInflater
7+ import androidx.annotation.NonNull
78import androidx.constraintlayout.widget.ConstraintLayout
89import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.END
910import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.PARENT_ID
@@ -13,7 +14,6 @@ import org.schabi.newpipe.MainActivity
1314import org.schabi.newpipe.R
1415import org.schabi.newpipe.player.event.DisplayPortion
1516import org.schabi.newpipe.player.event.DoubleTapListener
16- import java.util.Optional
1717
1818class PlayerFastSeekOverlay (context : Context , attrs : AttributeSet ? ) :
1919 ConstraintLayout (context, attrs), DoubleTapListener {
@@ -64,7 +64,7 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
6464
6565 override fun onDoubleTapProgressDown (portion : DisplayPortion ) {
6666 val shouldForward: Boolean =
67- performListener?.shouldFastForward (portion)?.orElse( null ) ? : return
67+ performListener?.getFastSeekDirection (portion)?.directionAsBoolean ? : return
6868
6969 if (DEBUG )
7070 Log .d(
@@ -125,12 +125,22 @@ class PlayerFastSeekOverlay(context: Context, attrs: AttributeSet?) :
125125 interface PerformListener {
126126 fun onDoubleTap ()
127127 fun onDoubleTapEnd ()
128- fun shouldFastForward (portion : DisplayPortion ): Optional <Boolean >
128+ /* *
129+ * Determines if the playback should forward/rewind or do nothing.
130+ */
131+ @NonNull
132+ fun getFastSeekDirection (portion : DisplayPortion ): FastSeekDirection
129133 fun seek (forward : Boolean )
134+
135+ enum class FastSeekDirection (val directionAsBoolean : Boolean? ) {
136+ NONE (null ),
137+ FORWARD (true ),
138+ BACKWARD (false );
139+ }
130140 }
131141
132142 companion object {
133- private const val TAG = " PlayerSeekOverlay "
143+ private const val TAG = " PlayerFastSeekOverlay "
134144 private val DEBUG = MainActivity .DEBUG
135145 }
136146}
0 commit comments