[Android] Remove useless parameter in launchForeground
Nicolas Pomepuy
git at videolan.org
Tue Nov 30 06:26:37 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Nov 29 09:36:56 2021 +0100| [d15530f0a2b0ba27191b3d2edfe99e815b5064f2] | committer: Nicolas Pomepuy
Remove useless parameter in launchForeground
> https://code.videolan.org/videolan/vlc-android/commit/d15530f0a2b0ba27191b3d2edfe99e815b5064f2
---
.../src/main/java/org/videolan/resources/util/Extensions.kt | 10 ++++++----
.../vlc-android/src/org/videolan/vlc/DebugLogService.kt | 2 +-
.../vlc-android/src/org/videolan/vlc/ExternalMonitor.kt | 2 +-
.../vlc-android/src/org/videolan/vlc/MediaParsingService.kt | 4 ++--
.../vlc-android/src/org/videolan/vlc/PlaybackService.kt | 4 ++--
.../src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt | 4 ++--
.../vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt | 4 ++--
7 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/application/resources/src/main/java/org/videolan/resources/util/Extensions.kt b/application/resources/src/main/java/org/videolan/resources/util/Extensions.kt
index da5a40b43..044e5fe81 100644
--- a/application/resources/src/main/java/org/videolan/resources/util/Extensions.kt
+++ b/application/resources/src/main/java/org/videolan/resources/util/Extensions.kt
@@ -2,6 +2,8 @@ package org.videolan.resources.util
import android.content.Context
import android.content.Intent
+import android.os.Handler
+import android.os.Looper
import androidx.core.content.ContextCompat
import kotlinx.coroutines.*
import org.videolan.medialibrary.interfaces.Medialibrary
@@ -76,7 +78,7 @@ fun Context.startMedialibrary(firstRun: Boolean = false, upgrade: Boolean = fals
if (dbExists(coroutineContextProvider)) prefs.putSingle(KEY_MEDIALIBRARY_SCAN, ML_SCAN_ON)
}
val intent = Intent(ACTION_INIT).setClassName(applicationContext, MEDIAPARSING_SERVICE)
- launchForeground(this at startMedialibrary, intent
+ launchForeground(intent
.putExtra(EXTRA_FIRST_RUN, firstRun)
.putExtra(EXTRA_UPGRADE, upgrade)
.putExtra(EXTRA_REMOVE_DEVICE, removeDevices)
@@ -87,11 +89,11 @@ suspend fun Context.dbExists(coroutineContextProvider: CoroutineContextProvider
File(getDir("db", Context.MODE_PRIVATE).toString() + Medialibrary.VLC_MEDIA_DB_NAME).exists()
}
-fun Context.launchForeground(context: Context, intent: Intent) {
+fun Context.launchForeground(intent: Intent) {
try {
- context.startService(intent)
+ startService(intent)
} catch (e: IllegalStateException) {
intent.putExtra("foreground", true)
- ContextCompat.startForegroundService(context, intent)
+ ContextCompat.startForegroundService(this, intent)
}
}
\ No newline at end of file
diff --git a/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt b/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt
index 8265f0da7..66a00c289 100644
--- a/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/DebugLogService.kt
@@ -145,7 +145,7 @@ class DebugLogService : Service(), Logcat.Callback, Runnable {
logcat = Logcat()
logcat!!.start(this)
- launchForeground(this, Intent(this, DebugLogService::class.java))
+ launchForeground(Intent(this, DebugLogService::class.java))
sendMessage(MSG_STARTED, null)
}
diff --git a/application/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt b/application/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
index 2cf199ea8..cbe2dd402 100644
--- a/application/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
+++ b/application/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
@@ -145,7 +145,7 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
val scanOpt = if (Settings.showTvUi) ML_SCAN_ON
else Settings.getInstance(ctx).getInt(KEY_MEDIALIBRARY_SCAN, -1)
if (scanOpt == ML_SCAN_ON)
- AppScope.launch { ctx.launchForeground(ctx,Intent(ACTION_CHECK_STORAGES, null, ctx, MediaParsingService::class.java)) }
+ AppScope.launch { ctx.launchForeground(Intent(ACTION_CHECK_STORAGES, null, ctx, MediaParsingService::class.java)) }
}
val usbManager = ctx.getSystemService<UsbManager>() ?: return
devices.add(ArrayList(usbManager.deviceList.values))
diff --git a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index 439ef7a6b..ffc7f2ae0 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -531,11 +531,11 @@ data class ScanProgress(val parsing: Float, val progressText: String, val inDisc
data class DiscoveryError(val entryPoint: String)
fun Context.reloadLibrary() {
- launchForeground(this, Intent(ACTION_RELOAD, null, this, MediaParsingService::class.java))
+ launchForeground(Intent(ACTION_RELOAD, null, this, MediaParsingService::class.java))
}
fun Context.rescan() {
- launchForeground(this, Intent(ACTION_FORCE_RELOAD, null, this, MediaParsingService::class.java))
+ launchForeground(Intent(ACTION_FORCE_RELOAD, null, this, MediaParsingService::class.java))
}
private sealed class MLAction
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 7aeb0cf16..49536416d 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -1641,12 +1641,12 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
fun start(context: Context) {
if (instance != null) return
val serviceIntent = Intent(context, PlaybackService::class.java)
- context.launchForeground(context, serviceIntent)
+ context.launchForeground(serviceIntent)
}
fun loadLastAudio(context: Context) {
val i = Intent(ACTION_REMOTE_LAST_PLAYLIST, null, context, PlaybackService::class.java)
- context.launchForeground(context, i)
+ context.launchForeground(i)
}
fun hasRenderer() = renderer.value != null
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt
index 1f5c8b358..4ca21bcb3 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/MedialibraryUtils.kt
@@ -24,13 +24,13 @@ object MedialibraryUtils {
fun addDir(path: String, context: Context = AppContextProvider.appContext) {
val intent = Intent(ACTION_DISCOVER, null, context, MediaParsingService::class.java)
intent.putExtra(EXTRA_PATH, path)
- context.launchForeground(context, intent)
+ context.launchForeground(intent)
}
fun addDevice(path: String, context: Context) {
val intent = Intent(ACTION_DISCOVER_DEVICE, null, context, MediaParsingService::class.java)
intent.putExtra(EXTRA_PATH, path)
- context.launchForeground(context, intent)
+ context.launchForeground(intent)
}
fun isScanned(path: String): Boolean {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
index bc64ca635..ed638c414 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
@@ -543,7 +543,7 @@ object UiTools {
.setCancelable(false)
.setMessage(message)
.setPositiveButton(R.string.ml_external_storage_accept) { _, _ ->
- activity.launchForeground(activity, si)
+ activity.launchForeground(si)
}
.setNegativeButton(R.string.ml_external_storage_decline) { dialog, _ -> dialog.dismiss() }
builder.show()
@@ -553,7 +553,7 @@ object UiTools {
.setCancelable(false)
.setMessage(message)
.setPositiveButton(R.string.ml_external_storage_accept) { _, _ ->
- activity.launchForeground(activity, si)
+ activity.launchForeground(si)
}
.setNegativeButton(R.string.ml_external_storage_decline) { dialog, _ -> dialog.dismiss() }
builder.show()
More information about the Android
mailing list