Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VLC-Android
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ewout ter Hoeven
VLC-Android
Commits
851aa7f3
Commit
851aa7f3
authored
May 03, 2019
by
Geoffrey Métais
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lifecycle: Replace deprecated code
parent
4f271ce8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
+7
-7
No files found.
tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
View file @
851aa7f3
package
org.videolan.tools
import
androidx.lifecycle.GenericLifecycleObserver
import
androidx.lifecycle.Lifecycle
import
androidx.lifecycle.LifecycleObserver
import
androidx.lifecycle.LifecycleOwner
import
androidx.lifecycle.OnLifecycleEvent
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.ExperimentalCoroutinesApi
import
kotlinx.coroutines.Job
fun
LifecycleOwner
.
createJob
(
cancelEvent
:
Lifecycle
.
Event
=
Lifecycle
.
Event
.
ON_DESTROY
):
Job
=
Job
().
also
{
job
->
lifecycle
.
addObserver
(
object
:
GenericLifecycleObserver
{
override
fun
onStateChanged
(
source
:
LifecycleOwner
?,
event
:
Lifecycle
.
Event
)
{
if
(
event
==
cancelEvent
)
{
lifecycle
.
removeObserver
(
this
)
job
.
cancel
()
}
lifecycle
.
addObserver
(
object
:
LifecycleObserver
{
@OnLifecycleEvent
(
Lifecycle
.
Event
.
ON_DESTROY
)
fun
clear
()
{
lifecycle
.
removeObserver
(
this
)
job
.
cancel
()
}
})
}
...
...
Write
Preview
Markdown
is supported
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