mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val playerData = requireArguments().parcelable<PlayerData>(IntentData.playerData)!!
|
val playerData = requireArguments().parcelable<PlayerData>(IntentData.playerData)!!
|
||||||
@ -716,8 +721,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
openOrCloseFullscreenDialog(false)
|
openOrCloseFullscreenDialog(false)
|
||||||
updateResolutionOnFullscreenChange(false)
|
updateResolutionOnFullscreenChange(false)
|
||||||
|
|
||||||
restartActivityIfNeeded()
|
|
||||||
|
|
||||||
binding.player.updateMarginsByFullscreenMode()
|
binding.player.updateMarginsByFullscreenMode()
|
||||||
|
|
||||||
updateFullscreenButtonVisibility()
|
updateFullscreenButtonVisibility()
|
||||||
@ -1599,12 +1602,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
* If true, the activity will be automatically restarted
|
* If true, the activity will be automatically restarted
|
||||||
*/
|
*/
|
||||||
private fun restartActivityIfNeeded() {
|
private fun restartActivityIfNeeded() {
|
||||||
val lockedOrientations =
|
if (mainActivity.screenOrientationPref in lockedOrientations || viewModel.isOrientationChangeInProgress) return
|
||||||
listOf(
|
|
||||||
ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT,
|
|
||||||
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
|
||||||
)
|
|
||||||
if (mainActivity.screenOrientationPref in lockedOrientations) return
|
|
||||||
|
|
||||||
val orientation = resources.configuration.orientation
|
val orientation = resources.configuration.orientation
|
||||||
if (viewModel.isFullscreen.value != true && orientation != playerLayoutOrientation) {
|
if (viewModel.isFullscreen.value != true && orientation != playerLayoutOrientation) {
|
||||||
|
Loading…
Reference in New Issue
Block a user