aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core-ui/src/main/res-public/values/public.xml6
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/ui/ProgressAnimator.kt24
-rw-r--r--core/src/main/res-public/values/public.xml34
3 files changed, 41 insertions, 23 deletions
diff --git a/core-ui/src/main/res-public/values/public.xml b/core-ui/src/main/res-public/values/public.xml
index c8c2e56..f62ed25 100644
--- a/core-ui/src/main/res-public/values/public.xml
+++ b/core-ui/src/main/res-public/values/public.xml
@@ -1,10 +1,10 @@
<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
- <public name='kau_recycler_detached_background' type='layout' />
- <public name='kau_elastic_recycler_activity' type='layout' />
- <public name='kau_recycler_textslider' type='layout' />
<public name='Kau.Translucent' type='style' />
<public name='Kau.Translucent.NoAnimation' type='style' />
<public name='Kau.Translucent.SlideBottom' type='style' />
<public name='Kau.Translucent.SlideTop' type='style' />
+ <public name='kau_recycler_detached_background' type='layout' />
+ <public name='kau_elastic_recycler_activity' type='layout' />
+ <public name='kau_recycler_textslider' type='layout' />
</resources> \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/ui/ProgressAnimator.kt b/core/src/main/kotlin/ca/allanwang/kau/ui/ProgressAnimator.kt
index bb4cd88..f735f4d 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/ui/ProgressAnimator.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/ui/ProgressAnimator.kt
@@ -68,6 +68,11 @@ class ProgressAnimator private constructor() : ValueAnimator() {
start + (end - start) * trueProgress
}
}
+
+ /**
+ * Progress variant that takes in and returns int
+ */
+ fun progress(start: Int, end: Int, progress: Float): Int = (start + (end - start) * progress).toInt()
}
private val animators: MutableList<ProgressDisposableAction> = mutableListOf()
@@ -85,7 +90,7 @@ class ProgressAnimator private constructor() : ValueAnimator() {
/**
* Converts an action to a disposable action
*/
- private fun ProgressAction.asDisposable(): ProgressDisposableAction = { this(it); false }
+ private fun <T> ((T) -> Unit).asDisposable(): (T) -> Boolean = { this(it); false }
private fun ProgressRunnable.asDisposable(): ProgressDisposableRunnable = { this(); false }
@@ -109,13 +114,16 @@ class ProgressAnimator private constructor() : ValueAnimator() {
}
fun withAnimator(action: ProgressAction) =
- withDisposableAnimator(action.asDisposable())
+ withDisposableAnimator(action.asDisposable())
/**
* Range animator. Multiples the range by the current float progress before emission
*/
fun withAnimator(from: Float, to: Float, action: ProgressAction) =
- withDisposableAnimator(from, to, action.asDisposable())
+ withDisposableAnimator(from, to, action.asDisposable())
+
+ fun withAnimator(from: Int, to: Int, action: ProgressIntAction) =
+ withDisposableAnimator(from, to, action.asDisposable())
fun withDisposableAnimator(action: ProgressDisposableAction) = animators.add(action)
@@ -127,6 +135,14 @@ class ProgressAnimator private constructor() : ValueAnimator() {
}
}
+ fun withDisposableAnimator(from: Int, to: Int, action: ProgressIntDisposableAction) {
+ if (to != from) {
+ animators.add {
+ action(progress(from, to, it))
+ }
+ }
+ }
+
fun withRangeAnimator(min: Float, max: Float, start: Float, end: Float, progress: Float, action: ProgressAction) {
if (min >= max) {
throw IllegalArgumentException("Range animator must have min < max; currently min=$min, max=$max")
@@ -185,5 +201,7 @@ class ProgressAnimator private constructor() : ValueAnimator() {
private typealias ProgressAction = (Float) -> Unit
private typealias ProgressDisposableAction = (Float) -> Boolean
+private typealias ProgressIntAction = (Int) -> Unit
+private typealias ProgressIntDisposableAction = (Int) -> Boolean
private typealias ProgressRunnable = () -> Unit
private typealias ProgressDisposableRunnable = () -> Boolean
diff --git a/core/src/main/res-public/values/public.xml b/core/src/main/res-public/values/public.xml
index 9f8780e..a912019 100644
--- a/core/src/main/res-public/values/public.xml
+++ b/core/src/main/res-public/values/public.xml
@@ -1,20 +1,25 @@
<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
- <public name='kau_slide_in_top' type='anim' />
<public name='kau_slide_in_left' type='anim' />
- <public name='kau_slide_out_right' type='anim' />
+ <public name='kau_slide_out_left' type='anim' />
<public name='kau_slide_out_right_top' type='anim' />
- <public name='kau_fade_in' type='anim' />
- <public name='kau_slide_out_top' type='anim' />
- <public name='kau_slide_out_bottom' type='anim' />
<public name='kau_fade_out' type='anim' />
- <public name='kau_slide_out_left' type='anim' />
<public name='kau_slide_out_left_top' type='anim' />
+ <public name='kau_fade_in' type='anim' />
<public name='kau_slide_in_bottom' type='anim' />
<public name='kau_slide_in_right' type='anim' />
- <public name='kau_transparent' type='drawable' />
- <public name='kau_selectable_white' type='drawable' />
- <public name='kau_shadow_overlay' type='color' />
+ <public name='kau_slide_in_top' type='anim' />
+ <public name='kau_slide_out_top' type='anim' />
+ <public name='kau_slide_out_bottom' type='anim' />
+ <public name='kau_slide_out_right' type='anim' />
+ <public name='kau_enter_slide_right' type='transition' />
+ <public name='kau_exit_slide_right' type='transition' />
+ <public name='kau_exit_slide_top' type='transition' />
+ <public name='kau_enter_slide_bottom' type='transition' />
+ <public name='kau_enter_slide_left' type='transition' />
+ <public name='kau_exit_slide_left' type='transition' />
+ <public name='kau_enter_slide_top' type='transition' />
+ <public name='kau_exit_slide_bottom' type='transition' />
<public name='kau_activity_horizontal_margin' type='dimen' />
<public name='kau_activity_vertical_margin' type='dimen' />
<public name='kau_dialog_margin' type='dimen' />
@@ -99,6 +104,7 @@
<public name='kau_bullet_point' type='string' />
<public name='Kau' type='style' />
<public name='Kau.Translucent' type='style' />
+ <public name='kau_shadow_overlay' type='color' />
<public name='KauFadeIn' type='style' />
<public name='KauFadeInFadeOut' type='style' />
<public name='KauSlideInRight' type='style' />
@@ -106,12 +112,6 @@
<public name='KauSlideInFadeOut' type='style' />
<public name='KauSlideInSlideOutRight' type='style' />
<public name='KauSlideInSlideOutBottom' type='style' />
- <public name='kau_enter_slide_bottom' type='transition' />
- <public name='kau_enter_slide_top' type='transition' />
- <public name='kau_exit_slide_bottom' type='transition' />
- <public name='kau_exit_slide_top' type='transition' />
- <public name='kau_enter_slide_right' type='transition' />
- <public name='kau_exit_slide_right' type='transition' />
- <public name='kau_exit_slide_left' type='transition' />
- <public name='kau_enter_slide_left' type='transition' />
+ <public name='kau_transparent' type='drawable' />
+ <public name='kau_selectable_white' type='drawable' />
</resources> \ No newline at end of file