Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
12
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
4df113af
Commit
4df113af
authored
6 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Fix ExternalMonitor registration
parent
3fb19f09
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
+5
-3
5 additions, 3 deletions
vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
with
5 additions
and
3 deletions
vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
+
5
−
3
View file @
4df113af
...
...
@@ -37,7 +37,6 @@ import android.net.NetworkCapabilities
import
android.net.Uri
import
android.os.Build
import
android.text.TextUtils
import
android.util.Log
import
androidx.lifecycle.*
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
...
...
@@ -64,6 +63,7 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
private
lateinit
var
cm
:
ConnectivityManager
private
lateinit
var
ctx
:
Context
private
var
registered
=
false
private
val
actor
=
actor
<
DeviceAction
>(
capacity
=
Channel
.
CONFLATED
)
{
for
(
action
in
channel
)
when
(
action
){
...
...
@@ -101,7 +101,7 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
init
{
launch
{
if
(!
AndroidDevices
.
watchDevices
)
ProcessLifecycleOwner
.
get
().
lifecycle
.
addObserver
(
this
@ExternalMonitor
)
ProcessLifecycleOwner
.
get
().
lifecycle
.
addObserver
(
this
@ExternalMonitor
)
}
}
...
...
@@ -188,7 +188,7 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
@OnLifecycleEvent
(
Lifecycle
.
Event
.
ON_START
)
fun
register
()
{
Log
.
d
(
TAG
,
"register: "
)
if
(
registered
)
return
val
ctx
=
VLCApplication
.
getAppContext
()
val
networkFilter
=
IntentFilter
(
ConnectivityManager
.
CONNECTIVITY_ACTION
)
val
storageFilter
=
IntentFilter
(
Intent
.
ACTION_MEDIA_MOUNTED
)
...
...
@@ -200,6 +200,7 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
ctx
.
registerReceiver
(
this
,
networkFilter
)
ctx
.
registerReceiver
(
this
,
storageFilter
)
ctx
.
registerReceiver
(
this
,
otgFilter
)
registered
=
true
checkNewStorages
(
ctx
)
}
...
...
@@ -219,6 +220,7 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
if
(
AndroidDevices
.
watchDevices
)
return
val
ctx
=
VLCApplication
.
getAppContext
()
ctx
.
unregisterReceiver
(
this
)
registered
=
false
connected
.
value
=
false
devices
.
clear
()
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment