From eacfb6caef36aa1e7dea5097d1c08e342a023155 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 26 Sep 2021 21:21:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookActivity.kt | 20 +++++++++++++++++++ .../io/legado/app/ui/book/read/ReadMenu.kt | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index cb41cdb1e..6661d196f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -17,17 +17,20 @@ import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.constant.Status +import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookProgress import io.legado.app.data.entities.BookSource import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadTipConfig +import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.storage.AppWebDav import io.legado.app.help.storage.Backup import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.selector import io.legado.app.lib.theme.accentColor +import io.legado.app.model.NoStackTraceException import io.legado.app.model.ReadAloud import io.legado.app.model.ReadBook import io.legado.app.receiver.TimeBatteryReceiver @@ -783,6 +786,23 @@ class ReadBookActivity : ReadBookBaseActivity(), } } + override fun payAction() { + Coroutine.async(this) { + val book = ReadBook.book ?: throw NoStackTraceException("no book") + val chapter = appDb.bookChapterDao.getChapter(book.bookUrl, ReadBook.durChapterIndex) + ?: throw NoStackTraceException("no chapter") + val source = ReadBook.bookSource ?: throw NoStackTraceException("no book source") + val payAction = source.getContentRule().payAction + if (payAction.isNullOrEmpty()) { + throw NoStackTraceException("no pay action") + } + }.onSuccess { + + }.onError { + toastOnUi(it.localizedMessage) + } + } + /** * 朗读按钮 */ diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 4d7e55c3b..dfc5a21a6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -147,6 +147,9 @@ class ReadMenu @JvmOverloads constructor( tvLogin.setOnClickListener { callBack.showLogin() } + tvPay.setOnClickListener { + callBack.payAction() + } //亮度跟随 ivBrightnessAuto.setOnClickListener { context.putPrefBoolean("brightnessAuto", !brightnessAuto()) @@ -336,6 +339,7 @@ class ReadMenu @JvmOverloads constructor( fun onClickReadAloud() fun showReadMenuHelp() fun showLogin() + fun payAction() } }