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

Loading…
Cancel
Save