Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Geoffrey Métais
VLC-Android
Commits
59eefe9d
Commit
59eefe9d
authored
Jun 19, 2020
by
Geoffrey Métais
Browse files
Clear callbacks on delegates/models death
parent
9582db9c
Pipeline
#19179
passed with stage
in 3 minutes and 27 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
application/television/src/main/java/org/videolan/television/ui/NowPlayingDelegate.kt
View file @
59eefe9d
...
...
@@ -27,6 +27,7 @@ import androidx.lifecycle.viewModelScope
import
kotlinx.coroutines.ExperimentalCoroutinesApi
import
kotlinx.coroutines.ObsoleteCoroutinesApi
import
kotlinx.coroutines.flow.launchIn
import
kotlinx.coroutines.flow.onCompletion
import
kotlinx.coroutines.flow.onEach
import
kotlinx.coroutines.launch
import
org.videolan.libvlc.MediaPlayer
...
...
@@ -44,7 +45,9 @@ class NowPlayingDelegate(private val model: MainTvModel): PlaybackService.Callba
init
{
PlaylistManager
.
showAudioPlayer
.
observeForever
(
nowPlayingObserver
)
PlaybackService
.
serviceFlow
.
onEach
{
onServiceChanged
(
it
)
}.
launchIn
(
model
.
viewModelScope
)
PlaybackService
.
serviceFlow
.
onEach
{
onServiceChanged
(
it
)
}
.
onCompletion
{
service
?.
removeCallback
(
this
@NowPlayingDelegate
)
}
.
launchIn
(
model
.
viewModelScope
)
}
fun
onClear
()
{
...
...
application/vlc-android/src/org/videolan/vlc/viewmodels/PlaylistModel.kt
View file @
59eefe9d
...
...
@@ -27,6 +27,7 @@ import androidx.lifecycle.*
import
kotlinx.coroutines.*
import
kotlinx.coroutines.channels.actor
import
kotlinx.coroutines.flow.launchIn
import
kotlinx.coroutines.flow.onCompletion
import
kotlinx.coroutines.flow.onEach
import
org.videolan.medialibrary.Tools
import
org.videolan.medialibrary.interfaces.media.MediaWrapper
...
...
@@ -61,7 +62,9 @@ class PlaylistModel : ViewModel(), PlaybackService.Callback by EmptyPBSCallback
}
init
{
PlaybackService
.
serviceFlow
.
onEach
{
onServiceChanged
(
it
)
}.
launchIn
(
viewModelScope
)
PlaybackService
.
serviceFlow
.
onEach
{
onServiceChanged
(
it
)
}
.
onCompletion
{
onServiceChanged
(
null
)
}
.
launchIn
(
viewModelScope
)
}
private
fun
setup
(
service
:
PlaybackService
)
{
...
...
application/vlc-android/src/org/videolan/vlc/viewmodels/StreamsModel.kt
View file @
59eefe9d
...
...
@@ -27,6 +27,7 @@ import androidx.lifecycle.ViewModelProvider
import
androidx.lifecycle.viewModelScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.flow.launchIn
import
kotlinx.coroutines.flow.onCompletion
import
kotlinx.coroutines.flow.onEach
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
...
...
@@ -48,7 +49,9 @@ class StreamsModel(context: Context, private val showDummy: Boolean = false, cor
init
{
if
(
medialibrary
.
isStarted
)
refresh
()
PlaybackService
.
serviceFlow
.
onEach
{
onServiceChanged
(
it
)
}.
launchIn
(
viewModelScope
)
PlaybackService
.
serviceFlow
.
onEach
{
onServiceChanged
(
it
)
}
.
onCompletion
{
onServiceChanged
(
null
)
}
.
launchIn
(
viewModelScope
)
}
override
suspend
fun
updateList
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment