|
|
@ -22,8 +22,8 @@ import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
@Suppress("DEPRECATION") |
|
|
|
@Suppress("DEPRECATION") |
|
|
|
object ChapterProvider { |
|
|
|
object ChapterProvider { |
|
|
|
var viewWidth = 0 |
|
|
|
private var viewWidth = 0 |
|
|
|
var viewHeight = 0 |
|
|
|
private var viewHeight = 0 |
|
|
|
var paddingLeft = 0 |
|
|
|
var paddingLeft = 0 |
|
|
|
var paddingTop = 0 |
|
|
|
var paddingTop = 0 |
|
|
|
var visibleWidth = 0 |
|
|
|
var visibleWidth = 0 |
|
|
@ -440,19 +440,32 @@ object ChapterProvider { |
|
|
|
paragraphSpacing = ReadBookConfig.paragraphSpacing |
|
|
|
paragraphSpacing = ReadBookConfig.paragraphSpacing |
|
|
|
titleTopSpacing = ReadBookConfig.titleTopSpacing.dp |
|
|
|
titleTopSpacing = ReadBookConfig.titleTopSpacing.dp |
|
|
|
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dp |
|
|
|
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dp |
|
|
|
upViewSize() |
|
|
|
upVisibleSize() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 更新View尺寸 |
|
|
|
* 更新View尺寸 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun upViewSize() { |
|
|
|
fun upViewSize(width: Int, height: Int) { |
|
|
|
paddingLeft = ReadBookConfig.paddingLeft.dp |
|
|
|
if (width > 0 && height > 0) { |
|
|
|
paddingTop = ReadBookConfig.paddingTop.dp |
|
|
|
viewWidth = width |
|
|
|
visibleWidth = viewWidth - paddingLeft - ReadBookConfig.paddingRight.dp |
|
|
|
viewHeight = height |
|
|
|
visibleHeight = viewHeight - paddingTop - ReadBookConfig.paddingBottom.dp |
|
|
|
upVisibleSize() |
|
|
|
visibleRight = paddingLeft + visibleWidth |
|
|
|
} |
|
|
|
visibleBottom = paddingTop + visibleHeight |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 更新绘制尺寸 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private fun upVisibleSize() { |
|
|
|
|
|
|
|
if (viewWidth > 0 && viewHeight > 0) { |
|
|
|
|
|
|
|
paddingLeft = ReadBookConfig.paddingLeft.dp |
|
|
|
|
|
|
|
paddingTop = ReadBookConfig.paddingTop.dp |
|
|
|
|
|
|
|
visibleWidth = viewWidth - paddingLeft - ReadBookConfig.paddingRight.dp |
|
|
|
|
|
|
|
visibleHeight = viewHeight - paddingTop - ReadBookConfig.paddingBottom.dp |
|
|
|
|
|
|
|
visibleRight = paddingLeft + visibleWidth |
|
|
|
|
|
|
|
visibleBottom = paddingTop + visibleHeight |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val TextPaint.textHeight: Float |
|
|
|
val TextPaint.textHeight: Float |
|
|
|