@@ -26,6 +26,7 @@ internal class LyricsViewFragment : Fragment
2626 private LyricsAdapter _adapter ;
2727 private ImageView _backgroundImageView ;
2828 private TextView _songTitleTv , _artistAlbumTv ;
29+ private bool _isScreenKeepOnSetByThisFragment = false ;
2930
3031 public LyricsViewFragment ( BaseViewModelAnd viewModel )
3132 {
@@ -123,7 +124,6 @@ public override void OnViewCreated(View view, Bundle? savedInstanceState)
123124 {
124125 base . OnViewCreated ( view , savedInstanceState ) ;
125126 viewModel . CurrentFragment = this ;
126- UpdateScreenKeepOn ( ) ;
127127 }
128128
129129 public override void OnResume ( )
@@ -140,17 +140,19 @@ public override void OnPause()
140140
141141 private void UpdateScreenKeepOn ( )
142142 {
143- if ( viewModel ? . KeepScreenOnDuringLyrics == true && Activity ? . Window != null )
143+ if ( viewModel ? . KeepScreenOnDuringLyrics == true && Activity ? . Window != null && ! _isScreenKeepOnSetByThisFragment )
144144 {
145145 Activity . Window . AddFlags ( WindowManagerFlags . KeepScreenOn ) ;
146+ _isScreenKeepOnSetByThisFragment = true ;
146147 }
147148 }
148149
149150 private void ClearScreenKeepOn ( )
150151 {
151- if ( Activity ? . Window != null )
152+ if ( _isScreenKeepOnSetByThisFragment && Activity ? . Window != null )
152153 {
153154 Activity . Window . ClearFlags ( WindowManagerFlags . KeepScreenOn ) ;
155+ _isScreenKeepOnSetByThisFragment = false ;
154156 }
155157 }
156158 private void SetupBindings ( )
0 commit comments