aboutsummaryrefslogtreecommitdiff
path: root/core-ui/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-10-11 14:17:27 -0400
committerGitHub <noreply@github.com>2017-10-11 14:17:27 -0400
commitb87c75d607956393ad3b07751eb59ccf41726863 (patch)
tree28d580e11e1befcc3895f46f52b03966f0f922ec /core-ui/src
parentff597a7ef456fcb37160fa7a46b45296098ca413 (diff)
downloadkau-b87c75d607956393ad3b07751eb59ccf41726863.tar.gz
kau-b87c75d607956393ad3b07751eb59ccf41726863.tar.bz2
kau-b87c75d607956393ad3b07751eb59ccf41726863.zip
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
Diffstat (limited to 'core-ui/src')
-rw-r--r--core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt12
1 files changed, 7 insertions, 5 deletions
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)