优化
This commit is contained in:
@@ -3,6 +3,7 @@ package io.legado.app.ui.book.read.page.entities.column
|
|||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
import android.graphics.Path
|
import android.graphics.Path
|
||||||
|
import android.text.StaticLayout
|
||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
||||||
|
|
||||||
@@ -17,8 +18,8 @@ data class ReviewColumn(
|
|||||||
) : BaseColumn {
|
) : BaseColumn {
|
||||||
|
|
||||||
val countText by lazy {
|
val countText by lazy {
|
||||||
if (count > 99) {
|
if (count > 999) {
|
||||||
return@lazy "99+"
|
return@lazy "999"
|
||||||
}
|
}
|
||||||
return@lazy count.toString()
|
return@lazy count.toString()
|
||||||
}
|
}
|
||||||
@@ -28,19 +29,22 @@ data class ReviewColumn(
|
|||||||
fun drawToCanvas(canvas: Canvas, baseLine: Float, height: Float) {
|
fun drawToCanvas(canvas: Canvas, baseLine: Float, height: Float) {
|
||||||
if (count == 0) return
|
if (count == 0) return
|
||||||
path.reset()
|
path.reset()
|
||||||
path.moveTo(start, baseLine - height / 2)
|
path.moveTo(start + 1, baseLine - height * 2 / 5)
|
||||||
path.lineTo(start + height / 6, baseLine - height)
|
path.lineTo(start + height / 6, baseLine - height * 0.55f)
|
||||||
path.lineTo(end, baseLine - height)
|
path.lineTo(start + height / 6, baseLine - height * 0.8f)
|
||||||
path.lineTo(end, baseLine)
|
path.lineTo(end - 1, baseLine - height * 0.8f)
|
||||||
|
path.lineTo(end - 1, baseLine)
|
||||||
path.lineTo(start + height / 6, baseLine)
|
path.lineTo(start + height / 6, baseLine)
|
||||||
|
path.lineTo(start + height / 6, baseLine - height / 4)
|
||||||
path.close()
|
path.close()
|
||||||
ChapterProvider.reviewPaint.style = Paint.Style.STROKE
|
ChapterProvider.reviewPaint.style = Paint.Style.STROKE
|
||||||
canvas.drawPath(path, ChapterProvider.reviewPaint)
|
canvas.drawPath(path, ChapterProvider.reviewPaint)
|
||||||
ChapterProvider.reviewPaint.style = Paint.Style.FILL
|
ChapterProvider.reviewPaint.style = Paint.Style.FILL
|
||||||
|
val textWidth = StaticLayout.getDesiredWidth(countText, ChapterProvider.reviewPaint)
|
||||||
canvas.drawText(
|
canvas.drawText(
|
||||||
countText,
|
countText,
|
||||||
(start + end) / 2,
|
start + height / 6 + textWidth * 0.45f,
|
||||||
baseLine - height / 6,
|
baseLine - height / 5,
|
||||||
ChapterProvider.reviewPaint
|
ChapterProvider.reviewPaint
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -667,7 +667,7 @@ object ChapterProvider {
|
|||||||
titlePaint = it.first
|
titlePaint = it.first
|
||||||
contentPaint = it.second
|
contentPaint = it.second
|
||||||
reviewPaint.color = contentPaint.color
|
reviewPaint.color = contentPaint.color
|
||||||
reviewPaint.textSize = contentPaint.textSize * 0.6f
|
reviewPaint.textSize = contentPaint.textSize * 0.45f
|
||||||
reviewPaint.textAlign = Paint.Align.CENTER
|
reviewPaint.textAlign = Paint.Align.CENTER
|
||||||
}
|
}
|
||||||
//间距
|
//间距
|
||||||
|
|||||||
Reference in New Issue
Block a user