|
@@ -58,21 +58,21 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet)
|
|
|
strokeWidth = 8f
|
|
|
}
|
|
|
|
|
|
- override fun onDraw(canvas: Canvas?) {
|
|
|
+ override fun onDraw(canvas: Canvas) {
|
|
|
if (navigation == null) return
|
|
|
|
|
|
navigation?.regions?.forEach { region ->
|
|
|
val rect = region.rectF
|
|
|
|
|
|
// Scale rect from 1f,1f to screen width and height
|
|
|
- canvas?.withScale(width.toFloat(), height.toFloat()) {
|
|
|
+ canvas.withScale(width.toFloat(), height.toFloat()) {
|
|
|
regionPaint.color = context.getColor(region.type.colorRes)
|
|
|
drawRect(rect, regionPaint)
|
|
|
}
|
|
|
|
|
|
// Don't want scale anymore because it messes with drawText
|
|
|
// Translate origin to rect start (left, top)
|
|
|
- canvas?.withTranslation(x = (width * rect.left), y = (height * rect.top)) {
|
|
|
+ canvas.withTranslation(x = (width * rect.left), y = (height * rect.top)) {
|
|
|
// Calculate center of rect width on screen
|
|
|
val x = width * (abs(rect.left - rect.right) / 2)
|
|
|
|