diff options
Diffstat (limited to 'core-ui/src/main/kotlin/ca')
-rw-r--r-- | core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt | 8 | ||||
-rw-r--r-- | core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt | 9 |
2 files changed, 11 insertions, 6 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) } diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt index 6095a32..ab0e464 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt @@ -34,6 +34,9 @@ import ca.allanwang.kau.utils.navigationBarColor import ca.allanwang.kau.utils.scaleXY import ca.allanwang.kau.utils.statusBarColor import ca.allanwang.kau.utils.withAlpha +import kotlin.math.abs +import kotlin.math.log10 +import kotlin.math.min /** * A [FrameLayout] which responds to nested scrolls to create drag-dismissable layouts. @@ -136,7 +139,7 @@ class ElasticDragDismissFrameLayout @JvmOverloads constructor( } override fun onStopNestedScroll(child: View) { - if (Math.abs(totalDrag) >= dragDismissDistance) { + if (abs(totalDrag) >= dragDismissDistance) { dispatchDismissCallback() } else { // settle back to natural position @@ -192,7 +195,7 @@ class ElasticDragDismissFrameLayout @JvmOverloads constructor( } // how far have we dragged relative to the distance to perform a dismiss // (0–1 where 1 = dismiss distance). Decreasing logarithmically as we approach the limit - var dragFraction = Math.log10((1 + Math.abs(totalDrag) / dragDismissDistance).toDouble()).toFloat() + var dragFraction = log10((1 + abs(totalDrag) / dragDismissDistance).toDouble()).toFloat() // calculate the desired translation given the drag fraction var dragTo = dragFraction * dragDismissDistance * dragElacticity @@ -221,7 +224,7 @@ class ElasticDragDismissFrameLayout @JvmOverloads constructor( } dispatchDragCallback( dragFraction, dragTo, - Math.min(1f, Math.abs(totalDrag) / dragDismissDistance), totalDrag + min(1f, abs(totalDrag) / dragDismissDistance), totalDrag ) } |