aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt26
-rw-r--r--core/src/main/res-public/values/public.xml2
2 files changed, 26 insertions, 2 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt
index 76c314a..82cd577 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt
@@ -6,6 +6,8 @@ import android.app.ActivityOptions
import android.content.Context
import android.os.Bundle
import android.support.annotation.AnimRes
+import android.util.Pair
+import android.view.View
import ca.allanwang.kau.R
/**
@@ -25,7 +27,29 @@ infix fun Bundle.with(bundle: Bundle?): Bundle {
@SuppressLint("NewApi")
fun Bundle.withSceneTransitionAnimation(context: Context) {
if (context !is Activity || !buildIsLollipopAndUp) return
- this with ActivityOptions.makeSceneTransitionAnimation(context).toBundle()
+ val options = ActivityOptions.makeSceneTransitionAnimation(context)
+ putAll(options.toBundle())
+}
+
+/**
+ * Given the parent view and map of view ids to tags,
+ * create a scene transition animation
+ */
+fun Bundle.withSceneTransitionAnimation(parent: View, data: Map<Int, String>) =
+ withSceneTransitionAnimation(parent.context, data.mapKeys { (id, _) ->
+ parent.findViewById<View>(id)
+ })
+
+/**
+ * Given a mapping of views to tags,
+ * create a scene transition animation
+ */
+@SuppressLint("NewApi")
+fun Bundle.withSceneTransitionAnimation(context: Context, data: Map<View, String>) {
+ if (context !is Activity || !buildIsLollipopAndUp) return
+ val options = ActivityOptions.makeSceneTransitionAnimation(context,
+ *data.map { (view, tag) -> Pair(view, tag) }.toTypedArray())
+ putAll(options.toBundle())
}
fun Bundle.withCustomAnimation(context: Context,
diff --git a/core/src/main/res-public/values/public.xml b/core/src/main/res-public/values/public.xml
index c309a70..f831c6d 100644
--- a/core/src/main/res-public/values/public.xml
+++ b/core/src/main/res-public/values/public.xml
@@ -1,5 +1,5 @@
<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 -->
+<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
<public name='kau_exit_slide_bottom' type='transition' />
<public name='kau_exit_slide_left' type='transition' />
<public name='kau_enter_slide_right' type='transition' />