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
e79de908
Commit
e79de908
authored
5 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
TV: Fix history display race condition
Fix #879
parent
8172a955
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#7085
passed with stage
Stage:
in 3 minutes and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vlc-android/src/org/videolan/vlc/gui/tv/NowPlayingDelegate.kt
+5
-2
5 additions, 2 deletions
...android/src/org/videolan/vlc/gui/tv/NowPlayingDelegate.kt
vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt
+17
-13
17 additions, 13 deletions
...android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt
with
22 additions
and
15 deletions
vlc-android/src/org/videolan/vlc/gui/tv/NowPlayingDelegate.kt
+
5
−
2
View file @
e79de908
...
...
@@ -25,6 +25,7 @@ package org.videolan.vlc.gui.tv
import
androidx.lifecycle.Observer
import
kotlinx.coroutines.ExperimentalCoroutinesApi
import
kotlinx.coroutines.ObsoleteCoroutinesApi
import
kotlinx.coroutines.launch
import
org.videolan.libvlc.MediaPlayer
import
org.videolan.vlc.PlaybackService
import
org.videolan.vlc.util.EmptyPBSCallback
...
...
@@ -61,7 +62,9 @@ class NowPlayingDelegate(private val model: MainTvModel): PlaybackService.Callba
}
private
fun
updateCurrent
()
{
model
.
updateAudioCategories
()
model
.
updateHistory
()
model
.
run
{
updateAudioCategories
()
if
(
showHistory
)
launch
{
updateHistory
()
}
}
}
}
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/viewmodels/tv/MainTvModel.kt
+
17
−
13
View file @
e79de908
...
...
@@ -52,6 +52,7 @@ import org.videolan.vlc.repository.DirectoryRepository
import
org.videolan.vlc.util.*
private
const
val
NUM_ITEMS_PREVIEW
=
5
private
const
val
TAG
=
"MainTvModel"
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
...
...
@@ -64,7 +65,8 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
private
val
showInternalStorage
=
AndroidDevices
.
showInternalStorage
()
private
val
browserFavRepository
=
BrowserFavRepository
.
getInstance
(
context
)
private
var
updatedFavoritList
:
List
<
MediaWrapper
>
=
listOf
()
private
var
showHistory
=
false
var
showHistory
=
false
private
set
// LiveData
private
val
favorites
:
LiveData
<
List
<
BrowserFav
>>
=
browserFavRepository
.
browserFavorites
val
videos
:
LiveData
<
List
<
MediaLibraryItem
>>
=
MutableLiveData
()
...
...
@@ -78,6 +80,10 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
for
(
action
in
channel
)
updateBrowsers
()
}
private
val
historyActor
=
actor
<
Unit
>(
capacity
=
Channel
.
CONFLATED
)
{
for
(
action
in
channel
)
setHistory
()
}
private
val
favObserver
=
Observer
<
List
<
BrowserFav
>>
{
list
->
updatedFavoritList
=
convertFavorites
(
list
)
if
(!
updateActor
.
isClosedForSend
)
updateActor
.
offer
(
Unit
)
...
...
@@ -99,24 +105,22 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
fun
refresh
()
=
launch
{
updateAudioCategories
()
updateActor
.
offer
(
Unit
)
updateVideos
()
setHistory
()
historyActor
.
offer
(
Unit
)
updateActor
.
offer
(
Unit
)
}
private
fun
setHistory
()
{
private
suspend
fun
setHistory
()
{
if
(!
medialibrary
.
isStarted
)
return
val
historyEnabled
=
settings
.
getBoolean
(
PLAYBACK_HISTORY
,
true
)
if
(
showHistory
!=
historyEnabled
)
{
showHistory
=
historyEnabled
if
(!
historyEnabled
)
(
history
as
MutableLiveData
).
value
=
emptyList
()
else
updateHistory
()
}
showHistory
=
historyEnabled
if
(!
historyEnabled
)
(
history
as
MutableLiveData
).
value
=
emptyList
()
else
updateHistory
()
}
fun
updateHistory
()
{
if
(
showHistory
)
launch
{
(
history
as
MutableLiveData
).
value
=
withContext
(
Dispatchers
.
Default
)
{
medialibrary
.
lastMediaPlayed
().
toMutableList
()
}
}
suspend
fun
updateHistory
()
{
if
(!
showHistory
)
return
(
history
as
MutableLiveData
).
value
=
context
.
getFromMl
{
lastMediaPlayed
().
toMutableList
()
}
}
private
fun
updateVideos
()
=
launch
{
...
...
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