pull/48/head
kunfei 5 years ago
parent 437187ead6
commit 7a9169ae90
  1. 4
      app/src/main/java/io/legado/app/help/storage/OldRule.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt

@ -17,12 +17,12 @@ object OldRule {
fun jsonToBookSource(json: String): BookSource? {
var source: BookSource? = null
runCatching {
source = GSON.fromJsonObject<BookSource>(json)
source = GSON.fromJsonObject<BookSource>(json.trim())
}
runCatching {
if (source == null || source?.searchUrl.isNullOrBlank()) {
source = BookSource().apply {
val jsonItem = jsonPath.parse(json)
val jsonItem = jsonPath.parse(json.trim())
bookSourceUrl = jsonItem.readString("bookSourceUrl") ?: ""
bookSourceName = jsonItem.readString("bookSourceName") ?: ""
bookSourceGroup = jsonItem.readString("bookSourceGroup") ?: ""

@ -61,6 +61,8 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
} ?: toast("格式不对")
}
}
}.onError {
toast(it.localizedMessage)
}
}
}
Loading…
Cancel
Save