[Android] Improve AppScope implementation

Geoffrey Métais git at videolan.org
Wed Oct 10 15:29:33 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Oct 10 15:29:06 2018 +0200| [f56af830b56f32dce867d86710d26b2a46b7ad65] | committer: Geoffrey Métais

Improve AppScope implementation

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

 vlc-android/src/org/videolan/vlc/util/Workers.kt | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/Workers.kt b/vlc-android/src/org/videolan/vlc/util/Workers.kt
index 5a91accca..d2132a05b 100644
--- a/vlc-android/src/org/videolan/vlc/util/Workers.kt
+++ b/vlc-android/src/org/videolan/vlc/util/Workers.kt
@@ -1,11 +1,7 @@
 package org.videolan.vlc.util
 
 import android.os.Looper
-import kotlinx.coroutines.experimental.CoroutineScope
-import kotlinx.coroutines.experimental.Dispatchers
-import kotlinx.coroutines.experimental.Runnable
-import kotlinx.coroutines.experimental.launch
-import kotlin.coroutines.experimental.CoroutineContext
+import kotlinx.coroutines.experimental.*
 
 fun runBackground(runnable: Runnable) {
     if (Looper.myLooper() != Looper.getMainLooper()) runnable.run()
@@ -20,14 +16,6 @@ fun runIO(runnable: Runnable) {
     AppScope.launch(Dispatchers.IO) { runnable.run() }
 }
 
-object AppScope : CoroutineScope {
-    /**
-     * @suppress **Deprecated**: Deprecated in favor of top-level extension property
-     */
-    @Deprecated(level = DeprecationLevel.HIDDEN, message = "Deprecated in favor of top-level extension property")
-    override val isActive: Boolean
-        get() = true
-
-    override val coroutineContext: CoroutineContext
-        get() = Dispatchers.Main.immediate
+object AppScope : CoroutineScope by GlobalScope {
+    override val coroutineContext = Dispatchers.Main.immediate
 }
\ No newline at end of file



More information about the Android mailing list