feat: 优化代码

pull/141/head
kunfei 5 years ago
parent 532f130b74
commit 07a01f9820
  1. 6
      app/src/main/java/io/legado/app/web/controller/BookshelfController.kt
  2. 2
      app/src/main/java/io/legado/app/web/controller/SourceController.kt

@ -21,7 +21,7 @@ class BookshelfController {
} }
fun getChapterList(parameters: Map<String, List<String>>): ReturnData { fun getChapterList(parameters: Map<String, List<String>>): ReturnData {
val bookUrl = parameters["url"]?.get(0) val bookUrl = parameters["url"]?.getOrNull(0)
val returnData = ReturnData() val returnData = ReturnData()
if (bookUrl.isNullOrEmpty()) { if (bookUrl.isNullOrEmpty()) {
return returnData.setErrorMsg("参数url不能为空,请指定书籍地址") return returnData.setErrorMsg("参数url不能为空,请指定书籍地址")
@ -31,8 +31,8 @@ class BookshelfController {
} }
fun getBookContent(parameters: Map<String, List<String>>): ReturnData { fun getBookContent(parameters: Map<String, List<String>>): ReturnData {
val bookUrl = parameters["url"]?.get(0) val bookUrl = parameters["url"]?.getOrNull(0)
val index = parameters["index"]?.get(0)?.toInt() val index = parameters["index"]?.getOrNull(0)?.toInt()
val returnData = ReturnData() val returnData = ReturnData()
if (bookUrl.isNullOrEmpty()) { if (bookUrl.isNullOrEmpty()) {
return returnData.setErrorMsg("参数url不能为空,请指定书籍地址") return returnData.setErrorMsg("参数url不能为空,请指定书籍地址")

@ -58,7 +58,7 @@ class SourceController {
} }
fun getSource(parameters: Map<String, List<String>>): ReturnData { fun getSource(parameters: Map<String, List<String>>): ReturnData {
val url = parameters["url"]?.get(0) val url = parameters["url"]?.getOrNull(0)
val returnData = ReturnData() val returnData = ReturnData()
if (url.isNullOrEmpty()) { if (url.isNullOrEmpty()) {
return returnData.setErrorMsg("参数url不能为空,请指定书源地址") return returnData.setErrorMsg("参数url不能为空,请指定书源地址")

Loading…
Cancel
Save