feat: 优化代码

pull/141/head
kunfei 5 years ago
parent 39ed24d4dc
commit df38b79abe
  1. 10
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt
  2. 2
      app/src/main/res/layout/dialog_title_config.xml
  3. 12
      app/src/main/res/layout/view_book_page.xml

@ -28,6 +28,8 @@ object ChapterProvider {
var visibleBottom = 0
private var lineSpacingExtra = 0
private var paragraphSpacing = 0
private var titleTopSpacing = 0
private var titleBottomSpacing = 0
var typeface: Typeface = Typeface.SANS_SERIF
var titlePaint = TextPaint()
var contentPaint = TextPaint()
@ -97,7 +99,7 @@ object ChapterProvider {
stringBuilder: StringBuilder,
isTitle: Boolean
): Float {
var durY = y
var durY = if (isTitle) y + titleTopSpacing else y
val textPaint = if (isTitle) titlePaint else contentPaint
val layout = StaticLayout(
text, textPaint, visibleWidth,
@ -140,6 +142,9 @@ object ChapterProvider {
textPages.last().textLines.add(textLine)
textLine.upTopBottom(durY, textPaint)
durY += textPaint.textHeight * lineSpacingExtra / 10f
if (isTitle) {
durY += titleBottomSpacing
}
textPages.last().height = durY
}
durY += textPaint.textHeight * paragraphSpacing / 10f
@ -273,7 +278,8 @@ object ChapterProvider {
paragraphSpacing = ReadBookConfig.paragraphSpacing
titlePaint.textSize = (ReadBookConfig.textSize + 2).sp.toFloat()
contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat()
titleTopSpacing = ReadBookConfig.titleTopSpacing.dp
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dp
upSize()
}

@ -39,6 +39,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp"
app:max="100"
app:title="上间距" />
<io.legado.app.ui.widget.DetailSeekBar
@ -46,6 +47,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp"
app:max="100"
app:title="下间距" />
</LinearLayout>

@ -16,12 +16,14 @@
android:id="@+id/tv_top_left"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
android:layout_weight="1"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:textSize="12sp" />
</LinearLayout>
@ -56,12 +58,14 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true" />
android:singleLine="true"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_bottom_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:textSize="12sp" />
</LinearLayout>

Loading…
Cancel
Save