From 7a9169ae907c533825ff25a5b85d3189e806a0db Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 5 Nov 2019 22:26:13 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/help/storage/OldRule.kt | 4 ++-- .../legado/app/ui/book/source/edit/BookSourceEditViewModel.kt | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index 343a54087..47d97b360 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -17,12 +17,12 @@ object OldRule { fun jsonToBookSource(json: String): BookSource? { var source: BookSource? = null runCatching { - source = GSON.fromJsonObject(json) + source = GSON.fromJsonObject(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") ?: "" diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt index d50601117..5368c9650 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt @@ -61,6 +61,8 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat } ?: toast("格式不对") } } + }.onError { + toast(it.localizedMessage) } } } \ No newline at end of file