Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/build.gradle
#	app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugActivity.kt
pull/32/head
Administrator 5 years ago
commit 2d838462e4
  1. 13
      app/build.gradle
  2. 1
      app/src/main/java/io/legado/app/constant/Bus.kt
  3. 1
      app/src/main/java/io/legado/app/model/webbook/BookList.kt
  4. 11
      app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt
  5. 15
      app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt

@ -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'
}

@ -2,4 +2,5 @@ package io.legado.app.constant
object Bus {
const val RECREATE = "RECREATE"
const val SOURCE_DEBUG_LOG = "sourceDebugLog"
}

@ -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, "列表为空,按详情页解析")

@ -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 {

@ -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<EventMessage> = 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() {

Loading…
Cancel
Save