diff options
author | Allan Wang <me@allanwang.ca> | 2017-10-13 23:42:57 -0400 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-10-13 23:42:57 -0400 |
commit | afc1a0261985dcf8e7d73255c291098af1fdc966 (patch) | |
tree | 5fad06062bf746b14f807e619d011cf41d83cf59 /core-ui/src/main/kotlin/ca | |
parent | 1edb6e1ac1297f6feb229d8f89e07a88de1ae2e9 (diff) | |
parent | a0b35316f7bb6014ebbd3e18be870e860b30ea71 (diff) | |
download | kau-afc1a0261985dcf8e7d73255c291098af1fdc966.tar.gz kau-afc1a0261985dcf8e7d73255c291098af1fdc966.tar.bz2 kau-afc1a0261985dcf8e7d73255c291098af1fdc966.zip |
Merge dev3.4.4
Diffstat (limited to 'core-ui/src/main/kotlin/ca')
-rw-r--r-- | core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt | 12 |
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) |