pull/913/head
gedoor 4 years ago
parent 59cb14f0a1
commit 360cf2f4fe
  1. 6
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt
  2. 17
      app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt
  3. 2
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt

@ -68,7 +68,7 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
toastOnUi(R.string.error_get_book_info) toastOnUi(R.string.error_get_book_info)
} }
} ?: let { } ?: let {
chapterListData.postValue(null) chapterListData.postValue(emptyList())
toastOnUi(R.string.error_no_source) toastOnUi(R.string.error_no_source)
} }
} }
@ -104,11 +104,11 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
toastOnUi(R.string.chapter_list_empty) toastOnUi(R.string.chapter_list_empty)
} }
}.onError { }.onError {
chapterListData.postValue(null) chapterListData.postValue(emptyList())
toastOnUi(R.string.error_get_chapter_list) toastOnUi(R.string.error_get_chapter_list)
} }
} ?: let { } ?: let {
chapterListData.postValue(null) chapterListData.postValue(emptyList())
toastOnUi(R.string.error_no_source) toastOnUi(R.string.error_no_source)
} }
} }

@ -3,7 +3,6 @@ package io.legado.app.ui.config
import android.app.Activity.RESULT_OK import android.app.Activity.RESULT_OK
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import androidx.activity.result.contract.ActivityResultContracts
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import io.legado.app.R import io.legado.app.R
@ -104,13 +103,17 @@ object BackupRestoreUi {
} }
private fun restoreUsePermission(fragment: Fragment, path: String) { private fun restoreUsePermission(fragment: Fragment, path: String) {
fragment.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { PermissionsCompat.Builder(fragment)
Coroutine.async { .addPermissions(*Permissions.Group.STORAGE)
AppConfig.backupPath = path .rationale(R.string.tip_perm_request_storage)
Restore.restoreDatabase(path) .onGranted {
Restore.restoreConfig(path) Coroutine.async {
AppConfig.backupPath = path
Restore.restoreDatabase(path)
Restore.restoreConfig(path)
}
} }
}.launch(Permissions.Group.STORAGE) .request()
} }
fun importOldData(fragment: Fragment) { fun importOldData(fragment: Fragment) {

@ -53,7 +53,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
rssArticle = rssStar?.toRssArticle() ?: appDb.rssArticleDao.get(origin, link) rssArticle = rssStar?.toRssArticle() ?: appDb.rssArticleDao.get(origin, link)
rssArticle?.let { rssArticle -> rssArticle?.let { rssArticle ->
if (!rssArticle.description.isNullOrBlank()) { if (!rssArticle.description.isNullOrBlank()) {
contentLiveData.postValue(rssArticle.description) contentLiveData.postValue(rssArticle.description!!)
} else { } else {
rssSource?.let { rssSource?.let {
val ruleContent = it.ruleContent val ruleContent = it.ruleContent

Loading…
Cancel
Save