[Android] Remove useless scope and coroutine provider

Nicolas Pomepuy git at videolan.org
Wed Jan 20 09:54:28 UTC 2021


vlc-android | branch: 3.3.x | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jan 13 15:24:23 2021 +0100| [07dff8b935008cb707d91d442a121ea8eb464b5a] | committer: Nicolas Pomepuy

Remove useless scope and coroutine provider

(cherry picked from commit 4b218b2b42c420180c70cb994b5c7e91beb2a753)

> https://code.videolan.org/videolan/vlc-android/commit/07dff8b935008cb707d91d442a121ea8eb464b5a
---

 .../videolan/vlc/gui/dialogs/VideoTracksDialog.kt    | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VideoTracksDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VideoTracksDialog.kt
index c196125b2..102ce2e5b 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VideoTracksDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/VideoTracksDialog.kt
@@ -33,15 +33,18 @@ import android.widget.LinearLayout
 import android.widget.TextView
 import androidx.annotation.DrawableRes
 import androidx.core.content.ContextCompat
+import androidx.lifecycle.lifecycleScope
 import androidx.recyclerview.widget.LinearLayoutManager
 import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED
 import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.MainScope
 import kotlinx.coroutines.ObsoleteCoroutinesApi
 import kotlinx.coroutines.flow.launchIn
 import kotlinx.coroutines.flow.onEach
 import org.videolan.libvlc.MediaPlayer
-import org.videolan.tools.*
+import org.videolan.tools.DependencyProvider
+import org.videolan.tools.dp
+import org.videolan.tools.setGone
+import org.videolan.tools.setVisible
 import org.videolan.vlc.PlaybackService
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.PlayerOverlayTracksBinding
@@ -57,23 +60,11 @@ class VideoTracksDialog : VLCBottomSheetDialogFragment() {
 
     private lateinit var binding: PlayerOverlayTracksBinding
 
-    private val coroutineContextProvider: CoroutineContextProvider
-
     override fun initialFocusedView(): View = binding.subtitleTracks.emptyView
 
     lateinit var menuItemListener: (VideoTrackOption) -> Unit
     lateinit var trackSelectionListener: (Int, TrackType) -> Unit
 
-    init {
-        VideoTracksDialog.registerCreator { CoroutineContextProvider() }
-        coroutineContextProvider = VideoTracksDialog.get(0)
-    }
-
-    override fun onCreate(savedInstanceState: Bundle?) {
-        PlaybackService.serviceFlow.onEach { onServiceChanged(it) }.launchIn(MainScope())
-        super.onCreate(savedInstanceState)
-    }
-
     private fun onServiceChanged(service: PlaybackService?) {
         service?.let { playbackService ->
             if (playbackService.videoTracksCount <= 2) {
@@ -160,6 +151,7 @@ class VideoTracksDialog : VLCBottomSheetDialogFragment() {
             binding.audioTracks.options.collapse()
         }
         super.onViewCreated(view, savedInstanceState)
+        PlaybackService.serviceFlow.onEach { onServiceChanged(it) }.launchIn(lifecycleScope)
     }
 
     private fun generateSeparator(parent: ViewGroup, margin: Boolean = false) {



More information about the Android mailing list