|
|
@ -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 DEBUG_TIME_FORMAT = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault()) |
|
|
|
private val startTime: Long = System.currentTimeMillis() |
|
|
|
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 |
|
|
|
if (debugSource != sourceUrl || callback == null || !print) return |
|
|
|
var printMsg = msg |
|
|
|
var printMsg = msg |
|
|
|
if (isHtml) { |
|
|
|
if (isHtml) { |
|
|
|
printMsg = printMsg.htmlFormat() |
|
|
|
printMsg = printMsg.htmlFormat() |
|
|
|
} |
|
|
|
} |
|
|
|
printMsg = |
|
|
|
if (showTime) { |
|
|
|
String.format("%s %s", DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime)), printMsg) |
|
|
|
printMsg = |
|
|
|
|
|
|
|
String.format( |
|
|
|
|
|
|
|
"%s %s", |
|
|
|
|
|
|
|
DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime)), |
|
|
|
|
|
|
|
printMsg |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
callback?.printLog(state, printMsg) |
|
|
|
callback?.printLog(state, printMsg) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -70,7 +83,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { |
|
|
|
.onSuccess { searchBooks -> |
|
|
|
.onSuccess { searchBooks -> |
|
|
|
searchBooks?.let { |
|
|
|
searchBooks?.let { |
|
|
|
if (searchBooks.isNotEmpty()) { |
|
|
|
if (searchBooks.isNotEmpty()) { |
|
|
|
callback?.printLog(1, "") |
|
|
|
printLog(debugSource, 1, "", showTime = false) |
|
|
|
infoDebug(BookHelp.toBook(searchBooks[0])) |
|
|
|
infoDebug(BookHelp.toBook(searchBooks[0])) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -85,7 +98,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { |
|
|
|
printLog(debugSource, 1, "开始获取详情页") |
|
|
|
printLog(debugSource, 1, "开始获取详情页") |
|
|
|
val info = webBook.getBookInfo(book) |
|
|
|
val info = webBook.getBookInfo(book) |
|
|
|
.onSuccess { |
|
|
|
.onSuccess { |
|
|
|
callback?.printLog(1, "") |
|
|
|
printLog(debugSource, 1, "", showTime = false) |
|
|
|
tocDebug(book) |
|
|
|
tocDebug(book) |
|
|
|
} |
|
|
|
} |
|
|
|
.onError { |
|
|
|
.onError { |
|
|
@ -100,7 +113,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { |
|
|
|
.onSuccess { chapterList -> |
|
|
|
.onSuccess { chapterList -> |
|
|
|
chapterList?.let { |
|
|
|
chapterList?.let { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|
callback?.printLog(1, "") |
|
|
|
printLog(debugSource, 1, "", showTime = false) |
|
|
|
contentDebug(book, it[0]) |
|
|
|
contentDebug(book, it[0]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|