|
|
|
@ -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]) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|