From 7424e63557f2e4e92ce1674e32054fd8210679f3 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 16 Oct 2021 22:30:43 +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 --- .../main/java/io/legado/app/ui/book/read/page/PageView.kt | 7 ++++--- app/src/main/java/io/legado/app/ui/widget/BatteryView.kt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) 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 96d79c6e6..2cc6c5b46 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 @@ -8,13 +8,13 @@ import android.widget.FrameLayout import androidx.core.view.isGone import androidx.core.view.isInvisible import io.legado.app.R -import io.legado.app.base.BaseActivity import io.legado.app.constant.AppConst.timeFormat import io.legado.app.data.entities.Bookmark import io.legado.app.databinding.ViewBookPageBinding import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadTipConfig import io.legado.app.model.ReadBook +import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.widget.BatteryView @@ -25,7 +25,9 @@ import java.util.* * 阅读界面 */ class PageView(context: Context) : FrameLayout(context) { + private val binding = ViewBookPageBinding.inflate(LayoutInflater.from(context), this, true) + private val readBookActivity get() = activity as? ReadBookActivity private var battery = 100 private var tvTitle: BatteryView? = null private var tvTime: BatteryView? = null @@ -94,8 +96,7 @@ class PageView(context: Context) : FrameLayout(context) { */ fun upStatusBar() = with(binding.vwStatusBar) { setPadding(paddingLeft, context.statusBarHeight, paddingRight, paddingBottom) - isGone = - ReadBookConfig.hideStatusBar || (activity as? BaseActivity<*>)?.isInMultiWindow == true + isGone = ReadBookConfig.hideStatusBar || readBookActivity?.isInMultiWindow == true } private fun upTipStyle() = binding.run { diff --git a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt index 1c4aa8a6c..2b2cddb71 100644 --- a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt @@ -24,7 +24,7 @@ class BatteryView @JvmOverloads constructor( var isBattery = false set(value) { field = value - if (value) { + if (value && !isInEditMode) { super.setTypeface(batteryTypeface) postInvalidate() }