aboutsummaryrefslogtreecommitdiff
path: root/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-10-19 22:30:16 -0700
committerAllan Wang <me@allanwang.ca>2019-10-19 22:31:14 -0700
commit7007e61879bf33c09115b5d8bc16f27af2731045 (patch)
tree19bc5e07f16ce1b6b9d13c711fed5160e25bc3ad /core-ui/src/main/kotlin/ca/allanwang/kau/ui/views
parent63f920c3257e955da1ef63c91f8b5e2de5478e55 (diff)
downloadkau-7007e61879bf33c09115b5d8bc16f27af2731045.tar.gz
kau-7007e61879bf33c09115b5d8bc16f27af2731045.tar.bz2
kau-7007e61879bf33c09115b5d8bc16f27af2731045.zip
Convert java math to kotlin math
Diffstat (limited to 'core-ui/src/main/kotlin/ca/allanwang/kau/ui/views')
-rw-r--r--core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt8
1 files changed, 5 insertions, 3 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 474d40a..7669a2a 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
@@ -33,6 +33,8 @@ import ca.allanwang.kau.utils.dimenPixelSize
import ca.allanwang.kau.utils.getFont
import ca.allanwang.kau.utils.parentViewGroup
import ca.allanwang.kau.utils.toBitmap
+import kotlin.math.max
+import kotlin.math.min
/**
* A view which punches out some text from an opaque color block, allowing you to see through it.
@@ -133,7 +135,7 @@ class CutoutView @JvmOverloads constructor(
if (drawable!!.intrinsicHeight <= 0 || drawable!!.intrinsicWidth <= 0) throw IllegalArgumentException("Drawable's intrinsic size cannot be less than 0")
val targetWidth = width / PHI
val targetHeight = height / PHI
- bitmapScaling = Math.min(targetHeight / drawable!!.intrinsicHeight, targetWidth / drawable!!.intrinsicWidth)
+ bitmapScaling = min(targetHeight / drawable!!.intrinsicHeight, targetWidth / drawable!!.intrinsicWidth)
cutoutX = (width - drawable!!.intrinsicWidth * bitmapScaling) / 2
cutoutY = (height - drawable!!.intrinsicHeight * bitmapScaling) / 2
}
@@ -143,9 +145,9 @@ class CutoutView @JvmOverloads constructor(
*/
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
parentViewGroup.getWindowVisibleDisplayFrame(parentFrame)
- val minHeight = Math.max(minHeight, heightPercentage * parentFrame.height())
+ val minHeight = max(minHeight, heightPercentage * parentFrame.height())
val trueHeightMeasureSpec = if (minHeight > 0)
- MeasureSpec.makeMeasureSpec(Math.max(minHeight.toInt(), measuredHeight), MeasureSpec.EXACTLY)
+ MeasureSpec.makeMeasureSpec(max(minHeight.toInt(), measuredHeight), MeasureSpec.EXACTLY)
else heightMeasureSpec
super.onMeasure(widthMeasureSpec, trueHeightMeasureSpec)
}