diff --git a/app/build.gradle b/app/build.gradle index 4771d0825..7354986a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -83,7 +83,8 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.preference:preference:1.1.0-rc01' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'com.google.android.material:material:1.1.0-alpha08' + implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' + implementation 'com.google.android.material:material:1.1.0-alpha09' implementation 'com.google.android:flexbox:1.1.0' //lifecycle @@ -108,7 +109,7 @@ dependencies { implementation 'com.jeremyliao:live-event-bus-x:1.4.4' //协程 - def coroutines_version = '1.2.1' + def coroutines_version = '1.2.2' implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" @@ -116,8 +117,6 @@ dependencies { implementation 'com.google.code.gson:gson:2.8.5' implementation 'org.jsoup:jsoup:1.12.1' implementation 'cn.wanghaomiao:JsoupXpath:2.3.2' - // implementation 'org.apache.commons:commons-text:1.6' - // Default json parser for jsonpath implementation 'com.jayway.jsonpath:json-path:2.4.0' //JS @@ -135,4 +134,10 @@ dependencies { //颜色选择 implementation 'com.jaredrummler:colorpicker:1.1.0' + + //对话框 + implementation 'com.afollestad.material-dialogs:core:3.1.0' + implementation 'com.afollestad.material-dialogs:input:3.1.0' + implementation 'com.afollestad.material-dialogs:files:3.1.0' + } diff --git a/app/src/main/java/io/legado/app/constant/Bus.kt b/app/src/main/java/io/legado/app/constant/Bus.kt index 94d41fafb..98acde903 100644 --- a/app/src/main/java/io/legado/app/constant/Bus.kt +++ b/app/src/main/java/io/legado/app/constant/Bus.kt @@ -2,4 +2,5 @@ package io.legado.app.constant object Bus { const val RECREATE = "RECREATE" + const val SOURCE_DEBUG_LOG = "sourceDebugLog" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/model/webbook/BookList.kt b/app/src/main/java/io/legado/app/model/webbook/BookList.kt index dbc3c6af8..1fcc447dc 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookList.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookList.kt @@ -48,6 +48,7 @@ object BookList { reverse = true ruleList = ruleList.substring(1) } + SourceDebug.printLog(bookSource.bookSourceUrl, 1, "解析书籍列表") collections = analyzeRule.getElements(ruleList) if (collections.isEmpty() && bookSource.bookUrlPattern.isNullOrEmpty()) { SourceDebug.printLog(bookSource.bookSourceUrl, 1, "列表为空,按详情页解析") 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 919be87a6..7ca534ed9 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 @@ -5,7 +5,6 @@ import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.help.BookHelp import io.legado.app.help.coroutine.CompositeCoroutine -import io.legado.app.help.coroutine.Coroutine import io.legado.app.model.WebBook import io.legado.app.utils.htmlFormat import io.legado.app.utils.isAbsUrl @@ -66,11 +65,12 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { } } - fun searchDebug(key: String) { + private fun searchDebug(key: String) { val search = webBook.searchBook(key, 1) .onSuccess { searchBooks -> searchBooks?.let { if (searchBooks.isNotEmpty()) { + callback?.printLog(1, "") infoDebug(BookHelp.toBook(searchBooks[0])) } } @@ -81,9 +81,11 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { tasks.add(search) } - fun infoDebug(book: Book) { + private fun infoDebug(book: Book) { + printLog(debugSource, 1, "开始获取详情页") val info = webBook.getBookInfo(book) .onSuccess { + callback?.printLog(1, "") tocDebug(book) } .onError { @@ -93,10 +95,12 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { } private fun tocDebug(book: Book) { + printLog(debugSource, 1, "开始获取目录页") val chapterList = webBook.getChapterList(book) .onSuccess { chapterList -> chapterList?.let { if (it.isNotEmpty()) { + callback?.printLog(1, "") contentDebug(book, it[0]) } } @@ -108,6 +112,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { } private fun contentDebug(book: Book, bookChapter: BookChapter) { + printLog(debugSource, 1, "开始获取内容") val content = webBook.getContent(book, bookChapter) .onSuccess { content -> content?.let { diff --git a/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt b/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt index 5b7716804..df76cda3b 100644 --- a/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt +++ b/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt @@ -1,27 +1,18 @@ package io.legado.app.ui.sourcedebug import android.app.Application -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Observer import io.legado.app.App import io.legado.app.base.BaseViewModel +import io.legado.app.constant.Bus import io.legado.app.help.EventMessage import io.legado.app.model.WebBook import io.legado.app.model.webbook.SourceDebug +import io.legado.app.utils.postEvent class SourceDebugModel(application: Application) : BaseViewModel(application), SourceDebug.Callback { - private val logs: MutableLiveData = MutableLiveData() - private var webBook: WebBook? = null - fun observeLogs(owner: LifecycleOwner, observer: (EventMessage) -> Unit) { - logs.observe(owner, Observer { - observer(it) - }) - } - fun init(sourceUrl: String?) { sourceUrl?.let { //优先使用这个,不会抛出异常 @@ -40,7 +31,7 @@ class SourceDebugModel(application: Application) : BaseViewModel(application), S } override fun printLog(state: Int, msg: String) { - logs.postValue(EventMessage.obtain(state, msg)) + postEvent(Bus.SOURCE_DEBUG_LOG, EventMessage.obtain(state, msg)) } override fun onCleared() {