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
14
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
9778750a
Commit
9778750a
authored
5 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Browser: cancel task using a coroutineScope
parent
85622346
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#8642
passed with stage
in 26 minutes and 27 seconds
Changes
1
Pipelines
4
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 @
9778750a
...
...
@@ -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.
Geoffrey Métais
@Dekans
mentioned in commit
b8cce147
·
5 years ago
mentioned in commit
b8cce147
mentioned in commit b8cce1475834e431dd881895301ec1883dfad00b
Toggle commit list
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