pull/1352/head
gedoor 3 years ago
parent 3188937931
commit eacfb6caef
  1. 20
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.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)
}
}
/**
* 朗读按钮
*/

@ -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()
}
}

Loading…
Cancel
Save