Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
530
Issue boards
Milestones
Wiki
Code
Merge requests
11
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
bef126e8
Commit
bef126e8
authored
6 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Fix loading state in paged viewmodels
parent
9038981c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
+6
-4
6 additions, 4 deletions
...oid/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
with
6 additions
and
4 deletions
vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
+
6
−
4
View file @
bef126e8
package
org.videolan.vlc.viewmodels.paged
import
android.content.Context
import
androidx.lifecycle.MutableLiveData
import
androidx.paging.DataSource
import
androidx.paging.LivePagedListBuilder
import
androidx.paging.PagedList
import
androidx.paging.PositionalDataSource
import
android.content.Context
import
kotlinx.coroutines.experimental.launch
import
org.videolan.medialibrary.Medialibrary
import
org.videolan.medialibrary.media.MediaLibraryItem
...
...
@@ -14,7 +14,7 @@ import org.videolan.vlc.viewmodels.SortableModel
abstract
class
MLPagedModel
<
T
:
MediaLibraryItem
>(
context
:
Context
)
:
SortableModel
(
context
),
Medialibrary
.
OnMedialibraryReadyListener
{
protected
val
medialibrary
=
Medialibrary
.
getInstance
()
protected
var
filter
:
String
?
=
null
val
loading
=
MutableLiveData
<
Boolean
>().
apply
{
value
=
tru
e
}
val
loading
=
MutableLiveData
<
Boolean
>().
apply
{
value
=
fals
e
}
private
val
pagingConfig
=
PagedList
.
Config
.
Builder
()
.
setPageSize
(
100
)
...
...
@@ -71,8 +71,10 @@ abstract class MLPagedModel<T : MediaLibraryItem>(context: Context) : SortableMo
}
override
fun
refresh
():
Boolean
{
loading
.
postValue
(
true
)
pagedList
.
value
?.
dataSource
?.
invalidate
()
if
(
pagedList
.
value
?.
dataSource
?.
isInvalid
==
false
)
{
loading
.
postValue
(
true
)
pagedList
.
value
?.
dataSource
?.
invalidate
()
}
return
true
}
...
...
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