feat: 优化代码

pull/190/head
kunfei 5 years ago
parent 9022105955
commit 18a9e8d468
  1. 10
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt

@ -31,8 +31,8 @@ object ChapterProvider {
private var titleTopSpacing = 0
private var titleBottomSpacing = 0
var typeface: Typeface = Typeface.SANS_SERIF
var titlePaint = TextPaint()
var contentPaint = TextPaint()
lateinit var titlePaint: TextPaint
lateinit var contentPaint: TextPaint
init {
upStyle()
@ -262,18 +262,20 @@ object ChapterProvider {
Typeface.SANS_SERIF
}
//标题
titlePaint.isAntiAlias = true
titlePaint = TextPaint()
titlePaint.color = ReadBookConfig.durConfig.textColor()
titlePaint.letterSpacing = ReadBookConfig.letterSpacing
titlePaint.typeface = Typeface.create(typeface, Typeface.BOLD)
titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat()
titlePaint.isAntiAlias = true
//正文
contentPaint.isAntiAlias = true
contentPaint = TextPaint()
contentPaint.color = ReadBookConfig.durConfig.textColor()
contentPaint.letterSpacing = ReadBookConfig.letterSpacing
val style = if (ReadBookConfig.textBold) Typeface.BOLD else Typeface.NORMAL
contentPaint.typeface = Typeface.create(typeface, style)
contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat()
contentPaint.isAntiAlias = true
//间距
lineSpacingExtra = ReadBookConfig.lineSpacingExtra
paragraphSpacing = ReadBookConfig.paragraphSpacing

Loading…
Cancel
Save