Migrate feed to adapter delegates
This commit is contained in:
@@ -32,12 +32,13 @@ class LocalListFragment : MangaListFragment(), ActivityResultCallback<Uri> {
|
||||
viewModel.onMangaRemoved.observe(viewLifecycleOwner, ::onItemRemoved)
|
||||
}
|
||||
|
||||
override fun onRequestMoreItems(offset: Int) {
|
||||
if (offset == 0) {
|
||||
viewModel.onRefresh()
|
||||
}
|
||||
override fun onRefresh() {
|
||||
super.onRefresh()
|
||||
viewModel.onRefresh()
|
||||
}
|
||||
|
||||
override fun onScrolledToEnd() = Unit
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.opt_local, menu)
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
|
||||
@@ -45,11 +45,17 @@ class LocalListViewModel(
|
||||
}.asLiveData(viewModelScope.coroutineContext + Dispatchers.Default)
|
||||
|
||||
init {
|
||||
loadList()
|
||||
onRefresh()
|
||||
}
|
||||
|
||||
fun onRefresh() {
|
||||
loadList()
|
||||
launchLoadingJob {
|
||||
withContext(Dispatchers.Default) {
|
||||
val list = repository.getList(0)
|
||||
mangaList.value = list
|
||||
isEmptyState.postValue(list.isEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun importFile(uri: Uri) {
|
||||
@@ -69,7 +75,7 @@ class LocalListViewModel(
|
||||
}
|
||||
} ?: throw IOException("Cannot open input stream: $uri")
|
||||
}
|
||||
loadList()
|
||||
onRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,14 +94,4 @@ class LocalListViewModel(
|
||||
onMangaRemoved.call(manga)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadList() {
|
||||
launchLoadingJob {
|
||||
withContext(Dispatchers.Default) {
|
||||
val list = repository.getList(0)
|
||||
mangaList.value = list
|
||||
isEmptyState.postValue(list.isEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user