Fully manga list fragments to AdapterDelegates and mvvm

This commit is contained in:
Koitharu
2020-11-20 20:07:57 +02:00
parent 7e76e10591
commit 971f708e45
18 changed files with 203 additions and 135 deletions

View File

@@ -55,7 +55,7 @@ class LocalListViewModel(
fun importFile(uri: Uri) {
launchLoadingJob {
val contentResolver = context.contentResolver
val list = withContext(Dispatchers.Default) {
withContext(Dispatchers.Default) {
val name = MediaStoreCompat.getName(contentResolver, uri)
?: throw IOException("Cannot fetch name from uri: $uri")
if (!LocalMangaRepository.isFileSupported(name)) {
@@ -92,7 +92,9 @@ class LocalListViewModel(
private fun loadList() {
launchLoadingJob {
withContext(Dispatchers.Default) {
mangaList.value = repository.getList(0)
val list = repository.getList(0)
mangaList.value = list
isEmptyState.postValue(list.isEmpty())
}
}
}