Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Oct 14, 2023
1 parent 00a87da commit fb9189a
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
if (source.bookSourceUrl.isBlank() || source.bookSourceName.isBlank()) {
throw NoStackTraceException(context.getString(R.string.non_null_name_url))
}
if (!source.equal(bookSource ?: BookSource())) {
source.lastUpdateTime = System.currentTimeMillis()
if (source.equal(bookSource ?: BookSource())) {
return@execute source
}
bookSource?.let {
appDb.bookSourceDao.delete(it)
Expand Down Expand Up @@ -91,6 +91,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
val text1 = okHttpClient.newCallStrResponse { url(text) }.body
importSource(text1!!)
}

text.isJsonArray() -> {
if (text.contains("ruleSearchUrl") || text.contains("ruleFindUrl")) {
val items: List<Map<String, Any>> = jsonPath.parse(text).read("$")
Expand All @@ -100,6 +101,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
GSON.fromJsonArray<BookSource>(text).getOrThrow()[0]
}
}

text.isJsonObject() -> {
if (text.contains("ruleSearchUrl") || text.contains("ruleFindUrl")) {
val jsonItem = jsonPath.parse(text)
Expand All @@ -108,6 +110,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat
GSON.fromJsonObject<BookSource>(text).getOrThrow()
}
}

else -> throw NoStackTraceException("格式不对")
}
}
Expand Down

0 comments on commit fb9189a

Please sign in to comment.