Skip to content

Instantly share code, notes, and snippets.

@BambangHeriSetiawan
Last active August 14, 2019 17:42
Show Gist options
  • Save BambangHeriSetiawan/c3a7c483a61a6938ad1619c0ee86b058 to your computer and use it in GitHub Desktop.
Save BambangHeriSetiawan/c3a7c483a61a6938ad1619c0ee86b058 to your computer and use it in GitHub Desktop.
MainVM
/**
* 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