mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
fix: activity is sometimes unnecessarily restarted
This commit is contained in:
parent
1f172ed4a1
commit
7868695987
@ -354,6 +354,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
}
|
||||
}
|
||||
|
||||
private val lockedOrientations = listOf(
|
||||
ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT,
|
||||
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val playerData = requireArguments().parcelable<PlayerData>(IntentData.playerData)!!
|
||||
@ -716,8 +721,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
openOrCloseFullscreenDialog(false)
|
||||
updateResolutionOnFullscreenChange(false)
|
||||
|
||||
restartActivityIfNeeded()
|
||||
|
||||
binding.player.updateMarginsByFullscreenMode()
|
||||
|
||||
updateFullscreenButtonVisibility()
|
||||
@ -1599,12 +1602,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
* 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user