feat: 优化代码

pull/141/head
kunfei 5 years ago
parent bbd5005c63
commit 9adea2ee8b
  1. 1
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  2. 8
      app/src/main/java/io/legado/app/ui/widget/BatteryView.kt

@ -68,6 +68,7 @@ class ContentView(context: Context) : FrameLayout(context) {
tv_top_right.setTextColor(it)
tv_bottom_left.setTextColor(it)
tv_bottom_right.setTextColor(it)
battery_view.setColor(it)
}
if (hideStatusBar) {
tv_bottom_left.text = timeFormat.format(Date(System.currentTimeMillis()))

@ -9,6 +9,7 @@ import android.text.StaticLayout
import android.text.TextPaint
import android.util.AttributeSet
import android.view.View
import androidx.annotation.ColorInt
import io.legado.app.R
import io.legado.app.utils.dp
import io.legado.app.utils.getCompatColor
@ -23,7 +24,7 @@ class BatteryView(context: Context, attrs: AttributeSet?) : View(context, attrs)
private val polar = Rect()
init {
textPaint.textSize = 12.sp.toFloat()
textPaint.textSize = 10.sp.toFloat()
textPaint.strokeWidth = 1.dp.toFloat()
textPaint.isAntiAlias = true
textPaint.textAlign = Paint.Align.CENTER
@ -42,6 +43,11 @@ class BatteryView(context: Context, attrs: AttributeSet?) : View(context, attrs)
)
}
fun setColor(@ColorInt color: Int) {
textPaint.color = color
invalidate()
}
fun setBattery(battery: Int) {
this.battery = battery
invalidate()

Loading…
Cancel
Save