From c76ee0f55097d3630c6e93ade34c2e9c2649804c Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 10:53:44 +0800 Subject: [PATCH 01/17] up --- .../app/ui/booksource/BookSourceActivity.kt | 18 +++++++++- .../app/ui/sourcedebug/SourceDebugActivity.kt | 34 ++++++++++++++++++- app/src/main/res/menu/source_debug.xml | 11 ++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/menu/source_debug.xml diff --git a/app/src/main/java/io/legado/app/ui/booksource/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/booksource/BookSourceActivity.kt index 66ff91a1d..affb09a1f 100644 --- a/app/src/main/java/io/legado/app/ui/booksource/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/booksource/BookSourceActivity.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.booksource +import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem @@ -27,6 +28,7 @@ import kotlinx.android.synthetic.main.view_title_bar.* import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.launch import org.jetbrains.anko.startActivity +import org.jetbrains.anko.startActivityForResult class BookSourceActivity : VMBaseActivity(R.layout.activity_book_source), BookSourceAdapter.CallBack, @@ -36,6 +38,7 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity_ private lateinit var adapter: BookSourceAdapter private var bookSourceLiveDate: LiveData>? = null + val qrRequestCode = 101 override fun onActivityCreated(savedInstanceState: Bundle?) { setSupportActionBar(toolbar) @@ -55,7 +58,7 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity_ this.startActivity() } R.id.action_import_book_source_qr -> { - this.startActivity() + this.startActivityForResult(qrRequestCode) } R.id.action_select_all -> { launch(IO) { @@ -135,4 +138,17 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity_ override fun edit(bookSource: BookSource) { startActivity(Pair("data", bookSource.bookSourceUrl)) } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + when (requestCode) { + qrRequestCode -> { + if (resultCode == RESULT_OK) { + data?.getStringExtra("result")?.let { + + } + } + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt b/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt index 609689873..ee15278ea 100644 --- a/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt +++ b/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt @@ -1,6 +1,9 @@ package io.legado.app.ui.sourcedebug +import android.content.Intent import android.os.Bundle +import android.view.Menu +import android.view.MenuItem import android.view.View import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.LinearLayoutManager @@ -9,12 +12,13 @@ import io.legado.app.base.VMBaseActivity import io.legado.app.constant.Bus import io.legado.app.help.EventMessage import io.legado.app.lib.theme.ATH -import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.accentColor +import io.legado.app.ui.qrcode.QrCodeActivity import io.legado.app.utils.getViewModel import io.legado.app.utils.observeEvent import kotlinx.android.synthetic.main.activity_source_debug.* import kotlinx.android.synthetic.main.view_title_bar.* +import org.jetbrains.anko.startActivityForResult import org.jetbrains.anko.toast class SourceDebugActivity : VMBaseActivity(R.layout.activity_source_debug) { @@ -23,6 +27,7 @@ class SourceDebugActivity : VMBaseActivity(R.layout.activity_s get() = getViewModel(SourceDebugModel::class.java) private lateinit var adapter: SourceDebugAdapter + val qrRequestCode = 101 override fun onActivityCreated(savedInstanceState: Bundle?) { viewModel.init(intent.getStringExtra("key")) @@ -65,6 +70,33 @@ class SourceDebugActivity : VMBaseActivity(R.layout.activity_s }) } + override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.source_debug, menu) + return super.onCompatCreateOptionsMenu(menu) + } + + override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.action_scan -> { + startActivityForResult(qrRequestCode) + } + } + return super.onCompatOptionsItemSelected(item) + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + when (requestCode) { + qrRequestCode -> { + if (resultCode == RESULT_OK) { + data?.getStringExtra("result")?.let { + startSearch(it) + } + } + } + } + } + override fun observeLiveBus() { observeEvent(Bus.SOURCE_DEBUG_LOG) { adapter.addItem(it.obj as String) diff --git a/app/src/main/res/menu/source_debug.xml b/app/src/main/res/menu/source_debug.xml new file mode 100644 index 000000000..5b8b467f2 --- /dev/null +++ b/app/src/main/res/menu/source_debug.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file From 9fbdb796861edec968dfc398f05debe28e025276 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 11:02:23 +0800 Subject: [PATCH 02/17] up --- .../main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt | 2 +- app/src/main/java/io/legado/app/model/webbook/BookInfo.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 4c3545135..fead18fe8 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -195,7 +195,7 @@ class AnalyzeRule(private var book: BaseBook? = null) { Mode.Js -> result = evalJS(rule.rule, it) Mode.Json -> result = getAnalyzeByJSonPath(it).getString(rule.rule) Mode.XPath -> result = getAnalyzeByXPath(it).getString(rule.rule) - Mode.Default -> result = if (isUrl && !TextUtils.isEmpty(baseUrl)) { + Mode.Default -> result = if (isUrl) { getAnalyzeByJSoup(it).getString0(rule.rule) } else { getAnalyzeByJSoup(it).getString(rule.rule) diff --git a/app/src/main/java/io/legado/app/model/webbook/BookInfo.kt b/app/src/main/java/io/legado/app/model/webbook/BookInfo.kt index 988a1fa59..f678e5ed2 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookInfo.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookInfo.kt @@ -26,7 +26,7 @@ object BookInfo { SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取成功:$baseUrl") val infoRule = bookSource.getBookInfoRule() val analyzeRule = AnalyzeRule(book) - analyzeRule.setContent(body) + analyzeRule.setContent(body, baseUrl) infoRule.init?.let { if (it.isNotEmpty()) { SourceDebug.printLog(bookSource.bookSourceUrl, 1, "执行详情页初始化规则") From 5d81eb3233ac72c2fdc9b9a7511cfb93dcf309f5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 11:13:03 +0800 Subject: [PATCH 03/17] up --- .../main/java/io/legado/app/model/webbook/BookChapterList.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt index 3bd4be757..9f093df7a 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt @@ -116,8 +116,11 @@ object BookChapterList { } SourceDebug.printLog(bookSource.bookSourceUrl, 1, TextUtils.join(",", nextUrlList), printLog) } + SourceDebug.printLog(bookSource.bookSourceUrl, 1, "解析目录列表", printLog) val elements = analyzeRule.getElements(listRule) + SourceDebug.printLog(bookSource.bookSourceUrl, 1, "目录数${elements.size}", printLog) if (elements.isNotEmpty()) { + SourceDebug.printLog(bookSource.bookSourceUrl, 1, "获取目录", printLog) val nameRule = analyzeRule.splitSourceRule(tocRule.chapterName ?: "") val urlRule = analyzeRule.splitSourceRule(tocRule.chapterUrl ?: "") for (item in elements) { @@ -131,6 +134,7 @@ object BookChapterList { chapterList.add(bookChapter) } } + SourceDebug.printLog(bookSource.bookSourceUrl, 1, "${chapterList[0].title}${chapterList[0].url}", printLog) } return ChapterData(chapterList, nextUrlList) } From 5b91e44e064cbd1d5a5eb3b89d4c1a18c2b403d2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 11:24:29 +0800 Subject: [PATCH 04/17] up --- .../java/io/legado/app/ui/booksource/BookSourceActivity.kt | 2 +- .../java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/booksource/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/booksource/BookSourceActivity.kt index affb09a1f..4be37daca 100644 --- a/app/src/main/java/io/legado/app/ui/booksource/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/booksource/BookSourceActivity.kt @@ -38,7 +38,7 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity_ private lateinit var adapter: BookSourceAdapter private var bookSourceLiveDate: LiveData>? = null - val qrRequestCode = 101 + private val qrRequestCode = 101 override fun onActivityCreated(savedInstanceState: Bundle?) { setSupportActionBar(toolbar) diff --git a/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt b/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt index ee15278ea..66d25642d 100644 --- a/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt +++ b/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt @@ -15,6 +15,7 @@ import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.ui.qrcode.QrCodeActivity import io.legado.app.utils.getViewModel +import io.legado.app.utils.hideSoftInput import io.legado.app.utils.observeEvent import kotlinx.android.synthetic.main.activity_source_debug.* import kotlinx.android.synthetic.main.view_title_bar.* @@ -27,7 +28,7 @@ class SourceDebugActivity : VMBaseActivity(R.layout.activity_s get() = getViewModel(SourceDebugModel::class.java) private lateinit var adapter: SourceDebugAdapter - val qrRequestCode = 101 + private val qrRequestCode = 101 override fun onActivityCreated(savedInstanceState: Bundle?) { viewModel.init(intent.getStringExtra("key")) @@ -51,6 +52,7 @@ class SourceDebugActivity : VMBaseActivity(R.layout.activity_s search_view.clearFocus() search_view.setOnQueryTextListener(object : SearchView.OnQueryTextListener { override fun onQueryTextSubmit(query: String?): Boolean { + search_view.hideSoftInput() startSearch(query ?: "我的") return true } From b5f02bccf04242b5da79d5e7470af0013c090ab5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 11:30:18 +0800 Subject: [PATCH 05/17] up --- app/src/main/java/io/legado/app/help/storage/Restore.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 74ec65055..62342bb9c 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -143,7 +143,7 @@ object Restore { ) source.ruleBookInfo = GSON.toJson(bookInfoRule) val chapterRule = TocRule( - chapterList = jsonItem.readString("ruleChapterUrlNext"), + chapterList = jsonItem.readString("ruleChapterList"), chapterName = jsonItem.readString("ruleChapterName"), chapterUrl = jsonItem.readString("ruleContentUrl"), nextTocUrl = jsonItem.readString("ruleChapterUrlNext") From 8ebe422cfd814bf481d358c6df2a063aa0084ea3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 11:46:54 +0800 Subject: [PATCH 06/17] up --- .../legado/app/model/webbook/SourceDebug.kt | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index 7ca534ed9..d9dd7df69 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -22,14 +22,27 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { private val DEBUG_TIME_FORMAT = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault()) private val startTime: Long = System.currentTimeMillis() - fun printLog(sourceUrl: String?, state: Int, msg: String, print: Boolean = true, isHtml: Boolean = false) { + fun printLog( + sourceUrl: String?, + state: Int, + msg: String, + print: Boolean = true, + isHtml: Boolean = false, + showTime: Boolean = true + ) { if (debugSource != sourceUrl || callback == null || !print) return var printMsg = msg if (isHtml) { printMsg = printMsg.htmlFormat() } - printMsg = - String.format("%s %s", DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime)), printMsg) + if (showTime) { + printMsg = + String.format( + "%s %s", + DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime)), + printMsg + ) + } callback?.printLog(state, printMsg) } @@ -70,7 +83,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { .onSuccess { searchBooks -> searchBooks?.let { if (searchBooks.isNotEmpty()) { - callback?.printLog(1, "") + printLog(debugSource, 1, "", showTime = false) infoDebug(BookHelp.toBook(searchBooks[0])) } } @@ -85,7 +98,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { printLog(debugSource, 1, "开始获取详情页") val info = webBook.getBookInfo(book) .onSuccess { - callback?.printLog(1, "") + printLog(debugSource, 1, "", showTime = false) tocDebug(book) } .onError { @@ -100,7 +113,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { .onSuccess { chapterList -> chapterList?.let { if (it.isNotEmpty()) { - callback?.printLog(1, "") + printLog(debugSource, 1, "", showTime = false) contentDebug(book, it[0]) } } From fe73c04a78667481a439281c74f51b0213cd652a Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 11:50:49 +0800 Subject: [PATCH 07/17] up --- app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index d9dd7df69..c493709cf 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -142,7 +142,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { fun printLog(state: Int, msg: String) } - fun printLog( + private fun printLog( sourceUrl: String?, state: Int, msg: String, From b8eec9ef72365507b8c2eb1ab20d056e4b36598a Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 11:52:43 +0800 Subject: [PATCH 08/17] up --- .../main/java/io/legado/app/model/webbook/SourceDebug.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index c493709cf..7767fe73d 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -36,12 +36,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { printMsg = printMsg.htmlFormat() } if (showTime) { - printMsg = - String.format( - "%s %s", - DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime)), - printMsg - ) + printMsg = "${DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime))} $printMsg" } callback?.printLog(state, printMsg) } From 579012632571c7cbd99aa60ca9764c90832cf0f3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 12:02:03 +0800 Subject: [PATCH 09/17] up --- app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index 7767fe73d..511b499bf 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -80,6 +80,8 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { if (searchBooks.isNotEmpty()) { printLog(debugSource, 1, "", showTime = false) infoDebug(BookHelp.toBook(searchBooks[0])) + } else { + printLog(debugSource, -1, "未获取到书籍") } } } @@ -110,6 +112,8 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { if (it.isNotEmpty()) { printLog(debugSource, 1, "", showTime = false) contentDebug(book, it[0]) + } else { + printLog(debugSource, -1, "目录列表为空") } } } From a4052e61c0db627a18f102e24e695d7f83900684 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 12:24:12 +0800 Subject: [PATCH 10/17] up --- .../io/legado/app/model/webbook/BookChapterList.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt index 9f093df7a..6719aff4c 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookChapterList.kt @@ -23,7 +23,7 @@ object BookChapterList { bookSource: BookSource, analyzeUrl: AnalyzeUrl ): List { - val chapterList = arrayListOf() + var chapterList = arrayListOf() val baseUrl: String = NetworkUtils.getUrl(response) val body: String? = response.body() body ?: throw Exception( @@ -58,7 +58,6 @@ object BookChapterList { } } } - if (reverse) chapterList.reverse() } else if (chapterData.nextUrl.size > 1) { val chapterDataList = arrayListOf>() for (item in chapterData.nextUrl) { @@ -85,8 +84,14 @@ object BookChapterList { chapterList.addAll(it) } } - if (reverse) chapterList.reverse() } + //去重 + if (!reverse) { + chapterList.reverse() + } + val lh = LinkedHashSet(chapterList) + chapterList = ArrayList(lh) + chapterList.reverse() return chapterList } From 54395c1385a90af2fd16f21fb089ebf38401ceac Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 15:03:53 +0800 Subject: [PATCH 11/17] up --- app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index 511b499bf..de180529a 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -22,6 +22,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { private val DEBUG_TIME_FORMAT = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault()) private val startTime: Long = System.currentTimeMillis() + @Synchronized fun printLog( sourceUrl: String?, state: Int, From c7d20c2510f60cd7ade14083b08f044505b8911e Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 15:33:55 +0800 Subject: [PATCH 12/17] up --- .../java/io/legado/app/model/webbook/SourceDebug.kt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index de180529a..304dad375 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -142,14 +142,4 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { fun printLog(state: Int, msg: String) } - private fun printLog( - sourceUrl: String?, - state: Int, - msg: String, - print: Boolean = true, - isHtml: Boolean = false - ): SourceDebug { - SourceDebug.printLog(sourceUrl, state, msg, print, isHtml) - return this - } } \ No newline at end of file From 60cd555a2dd91d0cec9e7cdfd1a594aa7d0a44b5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 15:38:24 +0800 Subject: [PATCH 13/17] up --- app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index 304dad375..3adbfa906 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -79,6 +79,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { .onSuccess { searchBooks -> searchBooks?.let { if (searchBooks.isNotEmpty()) { + printLog(debugSource, -1, "搜索完成") printLog(debugSource, 1, "", showTime = false) infoDebug(BookHelp.toBook(searchBooks[0])) } else { @@ -96,6 +97,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { printLog(debugSource, 1, "开始获取详情页") val info = webBook.getBookInfo(book) .onSuccess { + printLog(debugSource, -1, "详情页完成") printLog(debugSource, 1, "", showTime = false) tocDebug(book) } @@ -111,6 +113,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { .onSuccess { chapterList -> chapterList?.let { if (it.isNotEmpty()) { + printLog(debugSource, -1, "目录完成") printLog(debugSource, 1, "", showTime = false) contentDebug(book, it[0]) } else { From b8775cbe29719fdb5719c27cca15dd09017b293b Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 15:44:19 +0800 Subject: [PATCH 14/17] up --- .../main/java/io/legado/app/model/webbook/SourceDebug.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index 3adbfa906..1729ed97f 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -79,7 +79,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { .onSuccess { searchBooks -> searchBooks?.let { if (searchBooks.isNotEmpty()) { - printLog(debugSource, -1, "搜索完成") + printLog(debugSource, 1, "搜索完成") printLog(debugSource, 1, "", showTime = false) infoDebug(BookHelp.toBook(searchBooks[0])) } else { @@ -97,7 +97,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { printLog(debugSource, 1, "开始获取详情页") val info = webBook.getBookInfo(book) .onSuccess { - printLog(debugSource, -1, "详情页完成") + printLog(debugSource, 1, "详情页完成") printLog(debugSource, 1, "", showTime = false) tocDebug(book) } @@ -113,7 +113,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { .onSuccess { chapterList -> chapterList?.let { if (it.isNotEmpty()) { - printLog(debugSource, -1, "目录完成") + printLog(debugSource, 1, "目录完成") printLog(debugSource, 1, "", showTime = false) contentDebug(book, it[0]) } else { From e107d47385a82b7ddd15423d746b27cb2dd74781 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 15:50:18 +0800 Subject: [PATCH 15/17] up --- app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index 1729ed97f..a7cd9c5e7 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -20,7 +20,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { @SuppressLint("ConstantLocale") private val DEBUG_TIME_FORMAT = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault()) - private val startTime: Long = System.currentTimeMillis() + private var startTime: Long = System.currentTimeMillis() @Synchronized fun printLog( @@ -60,6 +60,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { fun startDebug(key: String) { cancelDebug() + startTime = System.currentTimeMillis() with(webBook) { if (key.isAbsUrl()) { val book = Book() From 1c6fddd61c4d56d2a2da7ffd7fc68149ab514b3c Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 15:51:00 +0800 Subject: [PATCH 16/17] up --- app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index a7cd9c5e7..804572049 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -1,6 +1,7 @@ package io.legado.app.model.webbook import android.annotation.SuppressLint +import android.util.Log import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.help.BookHelp @@ -39,6 +40,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { if (showTime) { printMsg = "${DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime))} $printMsg" } + Log.e("sourceDebugLog", printMsg) callback?.printLog(state, printMsg) } From 27bb0ea20a841b62cd3b2be5c8b54592297c48c5 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 2 Aug 2019 15:54:45 +0800 Subject: [PATCH 17/17] up --- app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index 804572049..a7cd9c5e7 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -1,7 +1,6 @@ package io.legado.app.model.webbook import android.annotation.SuppressLint -import android.util.Log import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.help.BookHelp @@ -40,7 +39,6 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { if (showTime) { printMsg = "${DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime))} $printMsg" } - Log.e("sourceDebugLog", printMsg) callback?.printLog(state, printMsg) }