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? { fun jsonToBookSource(json: String): BookSource? {
var source: BookSource? = null var source: BookSource? = null
runCatching { runCatching {
source = GSON.fromJsonObject<BookSource>(json) source = GSON.fromJsonObject<BookSource>(json.trim())
} }
runCatching { runCatching {
if (source == null || source?.searchUrl.isNullOrBlank()) { if (source == null || source?.searchUrl.isNullOrBlank()) {
source = BookSource().apply { source = BookSource().apply {
val jsonItem = jsonPath.parse(json) val jsonItem = jsonPath.parse(json.trim())
bookSourceUrl = jsonItem.readString("bookSourceUrl") ?: "" bookSourceUrl = jsonItem.readString("bookSourceUrl") ?: ""
bookSourceName = jsonItem.readString("bookSourceName") ?: "" bookSourceName = jsonItem.readString("bookSourceName") ?: ""
bookSourceGroup = jsonItem.readString("bookSourceGroup") ?: "" bookSourceGroup = jsonItem.readString("bookSourceGroup") ?: ""

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