Merge pull request #6 from gedoor/master

Sys code
pull/946/head
ag2s20150909 4 years ago committed by GitHub
commit b3545d3966
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      app/src/main/assets/updateLog.md
  2. 43
      app/src/main/java/io/legado/app/help/BookHelp.kt
  3. 2
      app/src/main/java/io/legado/app/service/CacheBookService.kt
  4. 5
      app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt

@ -3,6 +3,17 @@
* 关注合作公众号 **[小说拾遗]** 获取好看的小说。
* 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
**2021/04/08**
* 缓存时重新检查并缓存图片
* 订阅源调试添加源码查看
* web调试不输出源码
* 修复bug
* 换源优化
--- by ag2s20150909
* 修复localBook获取书名作者名的逻辑
* 修复导出的epub的标题文字过大的bug
* 优化图片排版
**2021/04/02**
* 修复bug
* 书源调试添加源码查看

@ -77,31 +77,6 @@ object BookHelp {
postEvent(EventBus.SAVE_CONTENT, bookChapter)
}
@Suppress("unused")
fun saveFont(book: Book, bookChapter: BookChapter, font: ByteArray) {
FileUtils.createFileIfNotExist(
downloadDir,
cacheFolderName,
book.getFolderName(),
"font",
bookChapter.getFontName()
).writeBytes(font)
}
fun getFontPath(book: Book, bookChapter: BookChapter): String? {
val fontFile = FileUtils.getFile(
downloadDir,
cacheFolderName,
book.getFolderName(),
"font",
bookChapter.getFontName()
)
if (fontFile.exists()) {
return fontFile.absolutePath
}
return null
}
suspend fun saveImage(book: Book, src: String) {
while (downloadImages.contains(src)) {
delay(100)
@ -174,6 +149,24 @@ object BookHelp {
}
}
fun hasImageContent(book: Book, bookChapter: BookChapter): Boolean {
if (!hasContent(book, bookChapter)) {
return false
}
getContent(book, bookChapter)?.let {
val matcher = AppPattern.imgPattern.matcher(it)
while (matcher.find()) {
matcher.group(1)?.let { src ->
val image = getImage(book, src)
if (!image.exists()) {
return false
}
}
}
}
return true
}
fun getContent(book: Book, bookChapter: BookChapter): String? {
if (book.isLocalTxt()) {
return LocalBook.getContext(book, bookChapter)

@ -184,7 +184,7 @@ class CacheBookService : BaseService() {
postDownloading(true)
return@async
}
if (!BookHelp.hasContent(book, bookChapter)) {
if (!BookHelp.hasImageContent(book, bookChapter)) {
webBook.getContent(this, book, bookChapter, context = searchPool)
.timeout(60000L)
.onError {

@ -22,6 +22,8 @@ class SourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) :
CoroutineScope by MainScope(),
Debug.Callback {
private val notPrintState = arrayOf(10, 20, 30, 40)
override fun onOpen() {
launch(IO) {
kotlin.runCatching {
@ -77,6 +79,9 @@ class SourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) :
}
override fun printLog(state: Int, msg: String) {
if (state in notPrintState) {
return
}
runOnIO {
runCatching {
send(msg)

Loading…
Cancel
Save