feat: 优化代码

pull/106/head
kunfei 5 years ago
parent b65065e6a6
commit fd8f05a024
  1. 3
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt

@ -26,6 +26,7 @@ object ChapterProvider {
private var paddingTop = 0 private var paddingTop = 0
private var lineSpacingExtra = 0f private var lineSpacingExtra = 0f
private var paragraphSpacing = 0 private var paragraphSpacing = 0
var typeface: Typeface = Typeface.SANS_SERIF
var titlePaint = TextPaint() var titlePaint = TextPaint()
var contentPaint = TextPaint() var contentPaint = TextPaint()
private var bodyIndent = BookHelp.bodyIndent private var bodyIndent = BookHelp.bodyIndent
@ -35,7 +36,7 @@ object ChapterProvider {
} }
fun upStyle(config: ReadBookConfig.Config) { fun upStyle(config: ReadBookConfig.Config) {
val typeface: Typeface = try { typeface = try {
val fontPath = App.INSTANCE.getPrefString(PreferKey.readBookFont) val fontPath = App.INSTANCE.getPrefString(PreferKey.readBookFont)
if (!TextUtils.isEmpty(fontPath)) { if (!TextUtils.isEmpty(fontPath)) {
Typeface.createFromFile(fontPath) Typeface.createFromFile(fontPath)

@ -19,7 +19,7 @@ import java.util.*
class ContentView : FrameLayout { class ContentView : FrameLayout {
var callBack: CallBack? = null var callBack: CallBack? = null
var headerHeight = 0 private var headerHeight = 0
private var pageSize: Int = 0 private var pageSize: Int = 0
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
@ -40,6 +40,10 @@ class ContentView : FrameLayout {
fun upStyle() { fun upStyle() {
ReadBookConfig.durConfig.apply { ReadBookConfig.durConfig.apply {
tv_top_left.typeface = ChapterProvider.typeface
tv_top_right.typeface = ChapterProvider.typeface
tv_bottom_left.typeface = ChapterProvider.typeface
tv_bottom_right.typeface = ChapterProvider.typeface
if (context.getPrefBoolean(PreferKey.hideStatusBar, false)) { if (context.getPrefBoolean(PreferKey.hideStatusBar, false)) {
//显示状态栏时隐藏header //显示状态栏时隐藏header
ll_header.visible() ll_header.visible()

Loading…
Cancel
Save