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. 15
      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, bookChapter: BookChapter,
content: String content: String
) { ) {
saveText(book, bookChapter, content) try {
saveImages(bookSource, book, bookChapter, content) saveText(book, bookChapter, content)
postEvent(EventBus.SAVE_CONTENT, Pair(book, bookChapter)) 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( fun saveText(

@ -7,13 +7,10 @@ import org.chromium.net.UploadDataSink
import java.io.IOException import java.io.IOException
import java.nio.ByteBuffer import java.nio.ByteBuffer
class BodyUploadProvider(body: RequestBody) : UploadDataProvider(), AutoCloseable { class BodyUploadProvider(private val body: RequestBody) : UploadDataProvider(), AutoCloseable {
private val body: RequestBody private val buffer = Buffer()
private val buffer: Buffer?
init { init {
buffer = Buffer()
this.body = body
try { try {
body.writeTo(buffer) body.writeTo(buffer)
} catch (e: IOException) { } catch (e: IOException) {
@ -32,7 +29,7 @@ class BodyUploadProvider(body: RequestBody) : UploadDataProvider(), AutoCloseabl
var read: Int var read: Int
var bytesRead = 0 var bytesRead = 0
while (bytesRead == 0) { while (bytesRead == 0) {
read = buffer!!.read(byteBuffer) read = buffer.read(byteBuffer)
bytesRead += read bytesRead += read
} }
uploadDataSink.onReadSucceeded(false) uploadDataSink.onReadSucceeded(false)
@ -40,12 +37,14 @@ class BodyUploadProvider(body: RequestBody) : UploadDataProvider(), AutoCloseabl
@Throws(IOException::class) @Throws(IOException::class)
override fun rewind(uploadDataSink: UploadDataSink) { override fun rewind(uploadDataSink: UploadDataSink) {
buffer.clear()
body.writeTo(buffer)
uploadDataSink.onRewindSucceeded() uploadDataSink.onRewindSucceeded()
} }
@Throws(IOException::class) @Throws(IOException::class)
override fun close() { override fun close() {
buffer?.close() buffer.close()
super.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.entities.TextPos
import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.ui.widget.BatteryView import io.legado.app.ui.widget.BatteryView
import io.legado.app.utils.activity import io.legado.app.utils.*
import io.legado.app.utils.dpToPx
import io.legado.app.utils.statusBarHeight
import io.legado.app.utils.visible
import splitties.views.backgroundColor import splitties.views.backgroundColor
import java.util.* import java.util.*
@ -223,11 +220,7 @@ class PageView(context: Context) : FrameLayout(context) {
* 更新背景 * 更新背景
*/ */
fun upBg() { fun upBg() {
if (ReadBookConfig.bgAlpha < 100) { binding.vwRoot.backgroundColor = ReadBookConfig.bgMeanColor
binding.vwRoot.backgroundColor = ReadBookConfig.bgMeanColor
} else {
binding.vwRoot.background = null
}
binding.vwBg.background = ReadBookConfig.bg binding.vwBg.background = ReadBookConfig.bg
upBgAlpha() upBgAlpha()
} }

Loading…
Cancel
Save