Last active
August 14, 2019 17:42
-
-
Save BambangHeriSetiawan/c3a7c483a61a6938ad1619c0ee86b058 to your computer and use it in GitHub Desktop.
MainVM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by simx on 14,August,2019 | |
*/ | |
class MainVM:BaseObservable() { | |
var movies : LiveData<PagedList<ResponseMovies.ResultsItem>> | |
var dataSource: MovieDataSourceFactory | |
init { | |
val config = PagedList.Config.Builder() | |
.setPageSize(10) | |
.setInitialLoadSizeHint(30) | |
.setEnablePlaceholders(false) | |
.build() | |
dataSource = MovieDataSourceFactory() | |
movies = LivePagedListBuilder(dataSource,config).build() | |
} | |
fun search(query: String, year:Int){ | |
dataSource.search(query,year) | |
movies.value?.dataSource?.invalidate() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment