Skip to content

Commit

Permalink
[APT-10128] Remove nullability on some jump to position actions
Browse files Browse the repository at this point in the history
  • Loading branch information
griffinfscribd committed Jun 5, 2024
1 parent b5a1ea4 commit 4418f8c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 36 deletions.
44 changes: 12 additions & 32 deletions Armadillo/src/main/java/com/scribd/armadillo/Reducer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,10 @@ internal object Reducer {
}
is FastForwardAction -> {
val playbackInfo = oldState.playbackInfo ?: throw ActionBeforeSetup(action)
val progress = if (action.seekPositionTarget != null) {
playbackInfo.progress.copy(
positionInDuration = action.seekPositionTarget,
currentChapterIndex = playbackInfo.audioPlayable.getChapterIndexAtOffset(action.seekPositionTarget))
} else {
playbackInfo.progress
}
oldState.copy(playbackInfo = playbackInfo.copy(
progress = progress,
progress = playbackInfo.progress.copy(
positionInDuration = action.seekPositionTarget,
currentChapterIndex = playbackInfo.audioPlayable.getChapterIndexAtOffset(action.seekPositionTarget)),
controlState = MediaControlState(
isSeeking = true,
isFastForwarding = true,
Expand All @@ -206,15 +201,10 @@ internal object Reducer {
}
is RewindAction -> {
val playbackInfo = oldState.playbackInfo ?: throw ActionBeforeSetup(action)
val progress = if (action.seekPositionTarget != null) {
playbackInfo.progress.copy(
positionInDuration = action.seekPositionTarget,
currentChapterIndex = playbackInfo.audioPlayable.getChapterIndexAtOffset(action.seekPositionTarget))
} else {
playbackInfo.progress
}
oldState.copy(playbackInfo = playbackInfo.copy(
progress = progress,
progress = playbackInfo.progress.copy(
positionInDuration = action.seekPositionTarget,
currentChapterIndex = playbackInfo.audioPlayable.getChapterIndexAtOffset(action.seekPositionTarget)),
controlState = MediaControlState(
isSeeking = true,
isRewinding = true,
Expand All @@ -223,15 +213,10 @@ internal object Reducer {
}
is SkipNextAction -> {
val playbackInfo = oldState.playbackInfo ?: throw ActionBeforeSetup(action)
val progress = if (action.seekPositionTarget != null) {
playbackInfo.progress.copy(
positionInDuration = action.seekPositionTarget,
currentChapterIndex = playbackInfo.audioPlayable.getChapterIndexAtOffset(action.seekPositionTarget))
} else {
playbackInfo.progress
}
oldState.copy(playbackInfo = playbackInfo.copy(
progress = progress,
progress = playbackInfo.progress.copy(
positionInDuration = action.seekPositionTarget,
currentChapterIndex = playbackInfo.audioPlayable.getChapterIndexAtOffset(action.seekPositionTarget)),
controlState = MediaControlState(
isSeeking = true,
isNextChapter = true,
Expand All @@ -240,15 +225,10 @@ internal object Reducer {
}
is SkipPrevAction -> {
val playbackInfo = oldState.playbackInfo ?: throw ActionBeforeSetup(action)
val progress = if (action.seekPositionTarget != null) {
playbackInfo.progress.copy(
positionInDuration = action.seekPositionTarget,
currentChapterIndex = playbackInfo.audioPlayable.getChapterIndexAtOffset(action.seekPositionTarget))
} else {
playbackInfo.progress
}
oldState.copy(playbackInfo = playbackInfo.copy(
progress = progress,
progress = playbackInfo.progress.copy(
positionInDuration = action.seekPositionTarget,
currentChapterIndex = playbackInfo.audioPlayable.getChapterIndexAtOffset(action.seekPositionTarget)),
controlState = MediaControlState(
isSeeking = true,
isPrevChapter = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ internal data class SeekAction(val isSeeking: Boolean, val seekPositionTarget: M
override val name = "Seeking: $isSeeking"
}

internal data class FastForwardAction(val seekPositionTarget: Milliseconds?) : Action {
internal data class FastForwardAction(val seekPositionTarget: Milliseconds) : Action {
override val name = "FastForwardAction: $seekPositionTarget"
}

internal data class RewindAction(val seekPositionTarget: Milliseconds?) : Action {
internal data class RewindAction(val seekPositionTarget: Milliseconds) : Action {
override val name = "RewindAction: $seekPositionTarget"
}

internal data class SkipNextAction(val seekPositionTarget: Milliseconds?) : Action {
internal data class SkipNextAction(val seekPositionTarget: Milliseconds) : Action {
override val name = "SkipNextAction: $seekPositionTarget"
}

internal data class SkipPrevAction(val seekPositionTarget: Milliseconds?) : Action {
internal data class SkipPrevAction(val seekPositionTarget: Milliseconds) : Action {
override val name = "SkipNextAction: $seekPositionTarget"
}

Expand Down

0 comments on commit 4418f8c

Please sign in to comment.