Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: activity is sometimes unnecessarily restarted #5949

Merged
merged 1 commit into from
May 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@
}
}

private val lockedOrientations = listOf(

Check failure on line 357 in app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 A multiline expression should start on a new line Raw Output: app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt:357:38: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT,
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE

Check failure on line 359 in app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 Missing trailing comma before ")" Raw Output: app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt:359:50: error: Missing trailing comma before ")" (standard:trailing-comma-on-call-site)
)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val playerData = requireArguments().parcelable<PlayerData>(IntentData.playerData)!!
Expand Down Expand Up @@ -716,8 +721,6 @@
openOrCloseFullscreenDialog(false)
updateResolutionOnFullscreenChange(false)

restartActivityIfNeeded()

binding.player.updateMarginsByFullscreenMode()

updateFullscreenButtonVisibility()
Expand Down Expand Up @@ -1599,12 +1602,7 @@
* If true, the activity will be automatically restarted
*/
private fun restartActivityIfNeeded() {
val lockedOrientations =
listOf(
ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT,
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
)
if (mainActivity.screenOrientationPref in lockedOrientations) return
if (mainActivity.screenOrientationPref in lockedOrientations || viewModel.isOrientationChangeInProgress) return

val orientation = resources.configuration.orientation
if (viewModel.isFullscreen.value != true && orientation != playerLayoutOrientation) {
Expand Down
Loading