Skip to content

Commit b1e422c

Browse files
authored
fix: access context safely when updating playback speed (#767)
* fix: access context safely when updating playback speed * fix: prevent java.lang.IllegalArgumentException when skipping
1 parent b75ead0 commit b1e422c

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
### Changed
9-
- Restored ability to show/hide notch area ([#749])
9+
- Restored ability to show/hide notch area ([#749])
1010

1111
### Fixed
1212
- Fixed overlap between editor controls and preview ([#752])

app/src/main/kotlin/org/fossify/gallery/fragments/VideoFragment.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -642,13 +642,12 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener,
642642

643643
val drawableId =
644644
if (isSlow) R.drawable.ic_playback_speed_slow_vector else R.drawable.ic_playback_speed_vector
645-
binding.bottomVideoTimeHolder.videoPlaybackSpeed
646-
.setDrawablesRelativeWithIntrinsicBounds(
647-
AppCompatResources.getDrawable(
648-
requireContext(),
649-
drawableId
645+
context?.let {
646+
binding.bottomVideoTimeHolder.videoPlaybackSpeed
647+
.setDrawablesRelativeWithIntrinsicBounds(
648+
AppCompatResources.getDrawable(it, drawableId)
650649
)
651-
)
650+
}
652651
}
653652

654653
@SuppressLint("SetTextI18n")
@@ -677,7 +676,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener,
677676
val curr = mExoPlayer!!.currentPosition
678677
var newPosition =
679678
if (forward) curr + FAST_FORWARD_VIDEO_MS else curr - FAST_FORWARD_VIDEO_MS
680-
newPosition = newPosition.coerceIn(0, mExoPlayer!!.duration)
679+
newPosition = newPosition.coerceIn(0, maxOf(mExoPlayer!!.duration, 0))
681680
setPosition(newPosition)
682681
if (!mIsPlaying) {
683682
togglePlayPause()

0 commit comments

Comments
 (0)