diff --git a/app/src/main/java/io/legado/app/help/book/BookHelp.kt b/app/src/main/java/io/legado/app/help/book/BookHelp.kt index 918daedba..88f82937b 100644 --- a/app/src/main/java/io/legado/app/help/book/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/book/BookHelp.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( diff --git a/app/src/main/java/io/legado/app/help/http/cronet/BodyUploadProvider.kt b/app/src/main/java/io/legado/app/help/http/cronet/BodyUploadProvider.kt index 860a24648..00b2a5145 100644 --- a/app/src/main/java/io/legado/app/help/http/cronet/BodyUploadProvider.kt +++ b/app/src/main/java/io/legado/app/help/http/cronet/BodyUploadProvider.kt @@ -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() } -} \ No newline at end of file +} diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 59d5efe28..d350b0eca 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -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() }