Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
529
Issue boards
Milestones
Wiki
Code
Merge requests
15
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
b8cce147
Commit
b8cce147
authored
5 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Browser: cancel task using a coroutineScope
(cherry picked from commit
9778750a
)
parent
7d12536b
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/providers/BrowserProvider.kt
+4
-5
4 additions, 5 deletions
...android/src/org/videolan/vlc/providers/BrowserProvider.kt
with
4 additions
and
5 deletions
vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+
4
−
5
View file @
b8cce147
...
...
@@ -53,7 +53,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
val
loading
=
MutableLiveData
<
Boolean
>().
apply
{
value
=
false
}
protected
var
mediabrowser
:
MediaBrowser
?
=
null
private
var
parsingJob
:
Completable
Job
?
=
null
private
var
parsingJob
:
Job
?
=
null
private
val
foldersContentMap
=
SimpleArrayMap
<
MediaLibraryItem
,
MutableList
<
MediaLibraryItem
>>()
protected
lateinit
var
browserChannel
:
Channel
<
Media
>
...
...
@@ -171,9 +171,8 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
val
directories
:
MutableList
<
AbstractMediaWrapper
>
=
ArrayList
()
val
files
:
MutableList
<
AbstractMediaWrapper
>
=
ArrayList
()
foldersContentMap
.
clear
()
val
job
=
SupervisorJob
(
coroutineContext
[
Job
]).
also
{
parsingJob
=
it
}
try
{
withContext
(
Dispatchers
.
IO
+
job
)
{
coroutineScope
{
// allow child coroutine to be cancelled without closing the actor.
parsingJob
=
launch
(
Dispatchers
.
IO
)
{
initBrowser
()
var
currentParsedPosition
=
-
1
loop@
while
(++
currentParsedPosition
<
currentMediaList
.
size
)
{
...
...
@@ -218,7 +217,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
files
.
clear
()
}
}
}
catch
(
ignored
:
CancellationException
)
{}
}
parsingJob
=
null
}
...
...
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