aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/ui
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/src/main/kotlin/ca/allanwang/kau/ui
parent63f920c3257e955da1ef63c91f8b5e2de5478e55 (diff)
downloadkau-7007e61879bf33c09115b5d8bc16f27af2731045.tar.gz
kau-7007e61879bf33c09115b5d8bc16f27af2731045.tar.bz2
kau-7007e61879bf33c09115b5d8bc16f27af2731045.zip
Convert java math to kotlin math
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/ui')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt3
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt4
2 files changed, 5 insertions, 2 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt
index 2a057cb..4e6326e 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/ui/views/CollapsibleViewDelegate.kt
@@ -23,6 +23,7 @@ import ca.allanwang.kau.utils.KAU_EXPANDED
import ca.allanwang.kau.utils.KAU_EXPANDING
import ca.allanwang.kau.utils.goneIf
import java.lang.ref.WeakReference
+import kotlin.math.roundToInt
/**
* Created by Allan Wang on 2017-08-03.
@@ -107,7 +108,7 @@ class CollapsibleViewDelegate : CollapsibleView {
val v = view ?: return Pair(0, 0)
val size = v.measuredHeight
v.goneIf(expansion == 0f && size == 0)
- return Pair(v.measuredWidth, Math.round(size * expansion))
+ return Pair(v.measuredWidth, (size * expansion).roundToInt())
}
private fun animateSize(target: Float) {
diff --git a/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt b/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt
index a972447..bd8f689 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt
@@ -27,6 +27,8 @@ import android.graphics.PorterDuff
import android.graphics.PorterDuffXfermode
import android.util.AttributeSet
import android.view.View
+import kotlin.math.hypot
+import kotlin.math.max
/**
* Created by Allan Wang on 2016-11-17.
@@ -93,7 +95,7 @@ class RippleCanvas @JvmOverloads constructor(
END -> h
else -> startY
}
- val maxRadius = Math.hypot(Math.max(x, w - x).toDouble(), Math.max(y, h - y).toDouble()).toFloat()
+ val maxRadius = hypot(max(x, w - x).toDouble(), max(y, h - y).toDouble()).toFloat()
val ripple = Ripple(color, x, y, 0f, maxRadius)
ripples.add(ripple)
val animator = ValueAnimator.ofFloat(0f, maxRadius)