From b87c75d607956393ad3b07751eb59ccf41726863 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 11 Oct 2017 14:17:27 -0400 Subject: fix/misc (#81) * Remove jvmstatic, fixes #68 * Create HO logging * Remove double null boolean notation * Replace multi if else with when * Ignore case in setSpan, closes #82 --- .../src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'core-ui') diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt index 9e8ac11..fc03563 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt @@ -147,14 +147,16 @@ class CutoutView @JvmOverloads constructor( paint.textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, mid, metrics) val maxLineWidth = paint.measureText(text) - return if (high - low < precision) low - else if (maxLineWidth > targetWidth) getSingleLineTextSize(text, paint, targetWidth, low, mid, precision, metrics) - else if (maxLineWidth < targetWidth) getSingleLineTextSize(text, paint, targetWidth, mid, high, precision, metrics) - else mid + return when { + high - low < precision -> low + maxLineWidth > targetWidth -> getSingleLineTextSize(text, paint, targetWidth, low, mid, precision, metrics) + maxLineWidth < targetWidth -> getSingleLineTextSize(text, paint, targetWidth, mid, high, precision, metrics) + else -> mid + } } private fun createBitmap() { - if (!(cutout?.isRecycled ?: true)) + if (cutout?.isRecycled == false) cutout?.recycle() if (width == 0 || height == 0) return cutout = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) -- cgit v1.2.3