debug添加查看源码

pull/931/head
gedoor 4 years ago
parent 645333a12b
commit 9d3d4824e7
  1. 2
      app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt
  2. 1
      app/src/main/java/io/legado/app/model/webBook/BookContent.kt
  3. 1
      app/src/main/java/io/legado/app/model/webBook/BookInfo.kt
  4. 1
      app/src/main/java/io/legado/app/model/webBook/BookList.kt
  5. 14
      app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt
  6. 13
      app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugModel.kt

@ -32,7 +32,7 @@ object BookChapterList {
appCtx.getString(R.string.error_get_web_content, baseUrl) appCtx.getString(R.string.error_get_web_content, baseUrl)
) )
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}")
Debug.log(bookSource.bookSourceUrl, body, state = 30)
val tocRule = bookSource.getTocRule() val tocRule = bookSource.getTocRule()
val nextUrlList = arrayListOf(baseUrl) val nextUrlList = arrayListOf(baseUrl)
var reverse = false var reverse = false

@ -33,6 +33,7 @@ object BookContent {
appCtx.getString(R.string.error_get_web_content, baseUrl) appCtx.getString(R.string.error_get_web_content, baseUrl)
) )
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}")
Debug.log(bookSource.bookSourceUrl, body, state = 40)
val mNextChapterUrl = if (!nextChapterUrl.isNullOrEmpty()) { val mNextChapterUrl = if (!nextChapterUrl.isNullOrEmpty()) {
nextChapterUrl nextChapterUrl
} else { } else {

@ -29,6 +29,7 @@ object BookInfo {
appCtx.getString(R.string.error_get_web_content, baseUrl) appCtx.getString(R.string.error_get_web_content, baseUrl)
) )
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}") Debug.log(bookSource.bookSourceUrl, "≡获取成功:${baseUrl}")
Debug.log(bookSource.bookSourceUrl, body, state = 20)
val analyzeRule = AnalyzeRule(book) val analyzeRule = AnalyzeRule(book)
analyzeRule.setContent(body).setBaseUrl(baseUrl) analyzeRule.setContent(body).setBaseUrl(baseUrl)
analyzeRule.setRedirectUrl(redirectUrl) analyzeRule.setRedirectUrl(redirectUrl)

@ -36,6 +36,7 @@ object BookList {
) )
) )
Debug.log(bookSource.bookSourceUrl, "≡获取成功:${analyzeUrl.ruleUrl}") Debug.log(bookSource.bookSourceUrl, "≡获取成功:${analyzeUrl.ruleUrl}")
Debug.log(bookSource.bookSourceUrl, body, state = 10)
val analyzeRule = AnalyzeRule(variableBook) val analyzeRule = AnalyzeRule(variableBook)
analyzeRule.setContent(body).setBaseUrl(baseUrl) analyzeRule.setContent(body).setBaseUrl(baseUrl)
analyzeRule.setRedirectUrl(baseUrl) analyzeRule.setRedirectUrl(baseUrl)

@ -96,8 +96,18 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_scan -> { R.id.menu_scan -> qrCodeResult.launch(null)
qrCodeResult.launch(null) R.id.menu_search_src -> {
}
R.id.menu_book_src -> {
}
R.id.menu_toc_src -> {
}
R.id.menu_content_src -> {
} }
R.id.menu_help -> showHelp() R.id.menu_help -> showHelp()
} }

@ -10,8 +10,11 @@ class BookSourceDebugModel(application: Application) : BaseViewModel(application
Debug.Callback { Debug.Callback {
private var webBook: WebBook? = null private var webBook: WebBook? = null
private var callback: ((Int, String) -> Unit)? = null private var callback: ((Int, String) -> Unit)? = null
var searchSrc: String? = null
var bookSrc: String? = null
var tocSrc: String? = null
var contentSrc: String? = null
fun init(sourceUrl: String?) { fun init(sourceUrl: String?) {
sourceUrl?.let { sourceUrl?.let {
@ -39,7 +42,13 @@ class BookSourceDebugModel(application: Application) : BaseViewModel(application
} }
override fun printLog(state: Int, msg: String) { override fun printLog(state: Int, msg: String) {
callback?.invoke(state, msg) when (state) {
10 -> searchSrc = msg
20 -> bookSrc = msg
30 -> tocSrc = msg
40 -> contentSrc = msg
else -> callback?.invoke(state, msg)
}
} }
override fun onCleared() { override fun onCleared() {

Loading…
Cancel
Save