diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index 8348dca02..3cb698ef3 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -68,7 +68,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { toastOnUi(R.string.error_get_book_info) } } ?: let { - chapterListData.postValue(null) + chapterListData.postValue(emptyList()) toastOnUi(R.string.error_no_source) } } @@ -104,11 +104,11 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { toastOnUi(R.string.chapter_list_empty) } }.onError { - chapterListData.postValue(null) + chapterListData.postValue(emptyList()) toastOnUi(R.string.error_get_chapter_list) } } ?: let { - chapterListData.postValue(null) + chapterListData.postValue(emptyList()) toastOnUi(R.string.error_no_source) } } diff --git a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt index 5204ef6c1..d538cc7a8 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt @@ -3,7 +3,6 @@ package io.legado.app.ui.config import android.app.Activity.RESULT_OK import android.content.Intent import android.net.Uri -import androidx.activity.result.contract.ActivityResultContracts import androidx.documentfile.provider.DocumentFile import androidx.fragment.app.Fragment import io.legado.app.R @@ -104,13 +103,17 @@ object BackupRestoreUi { } private fun restoreUsePermission(fragment: Fragment, path: String) { - fragment.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { - Coroutine.async { - AppConfig.backupPath = path - Restore.restoreDatabase(path) - Restore.restoreConfig(path) + PermissionsCompat.Builder(fragment) + .addPermissions(*Permissions.Group.STORAGE) + .rationale(R.string.tip_perm_request_storage) + .onGranted { + Coroutine.async { + AppConfig.backupPath = path + Restore.restoreDatabase(path) + Restore.restoreConfig(path) + } } - }.launch(Permissions.Group.STORAGE) + .request() } fun importOldData(fragment: Fragment) { diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt index f4cc85fff..cf3574f2e 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt @@ -53,7 +53,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application), rssArticle = rssStar?.toRssArticle() ?: appDb.rssArticleDao.get(origin, link) rssArticle?.let { rssArticle -> if (!rssArticle.description.isNullOrBlank()) { - contentLiveData.postValue(rssArticle.description) + contentLiveData.postValue(rssArticle.description!!) } else { rssSource?.let { val ruleContent = it.ruleContent