pull/2718/head
Horis 2 years ago
parent a5f45e9e98
commit 267ba0e542
  1. 11
      app/src/main/java/io/legado/app/help/book/BookHelp.kt
  2. 13
      app/src/main/java/io/legado/app/help/http/cronet/BodyUploadProvider.kt
  3. 11
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -86,9 +86,14 @@ object BookHelp {
bookChapter: BookChapter,
content: String
) {
saveText(book, bookChapter, content)
saveImages(bookSource, book, bookChapter, content)
postEvent(EventBus.SAVE_CONTENT, Pair(book, bookChapter))
try {
saveText(book, bookChapter, content)
saveImages(bookSource, book, bookChapter, content)
postEvent(EventBus.SAVE_CONTENT, Pair(book, bookChapter))
} catch (e: Exception) {
e.printStackTrace()
AppLog.put("保存正文失败 ${book.name} ${bookChapter.title}", e)
}
}
fun saveText(

@ -7,13 +7,10 @@ import org.chromium.net.UploadDataSink
import java.io.IOException
import java.nio.ByteBuffer
class BodyUploadProvider(body: RequestBody) : UploadDataProvider(), AutoCloseable {
private val body: RequestBody
private val buffer: Buffer?
class BodyUploadProvider(private val body: RequestBody) : UploadDataProvider(), AutoCloseable {
private val buffer = Buffer()
init {
buffer = Buffer()
this.body = body
try {
body.writeTo(buffer)
} catch (e: IOException) {
@ -32,7 +29,7 @@ class BodyUploadProvider(body: RequestBody) : UploadDataProvider(), AutoCloseabl
var read: Int
var bytesRead = 0
while (bytesRead == 0) {
read = buffer!!.read(byteBuffer)
read = buffer.read(byteBuffer)
bytesRead += read
}
uploadDataSink.onReadSucceeded(false)
@ -40,12 +37,14 @@ class BodyUploadProvider(body: RequestBody) : UploadDataProvider(), AutoCloseabl
@Throws(IOException::class)
override fun rewind(uploadDataSink: UploadDataSink) {
buffer.clear()
body.writeTo(buffer)
uploadDataSink.onRewindSucceeded()
}
@Throws(IOException::class)
override fun close() {
buffer?.close()
buffer.close()
super.close()
}
}

@ -18,10 +18,7 @@ import io.legado.app.ui.book.read.page.entities.TextPage
import io.legado.app.ui.book.read.page.entities.TextPos
import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.ui.widget.BatteryView
import io.legado.app.utils.activity
import io.legado.app.utils.dpToPx
import io.legado.app.utils.statusBarHeight
import io.legado.app.utils.visible
import io.legado.app.utils.*
import splitties.views.backgroundColor
import java.util.*
@ -223,11 +220,7 @@ class PageView(context: Context) : FrameLayout(context) {
* 更新背景
*/
fun upBg() {
if (ReadBookConfig.bgAlpha < 100) {
binding.vwRoot.backgroundColor = ReadBookConfig.bgMeanColor
} else {
binding.vwRoot.background = null
}
binding.vwRoot.backgroundColor = ReadBookConfig.bgMeanColor
binding.vwBg.background = ReadBookConfig.bg
upBgAlpha()
}

Loading…
Cancel
Save