aboutsummaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-02 23:38:51 -0500
committerGitHub <noreply@github.com>2018-01-02 23:38:51 -0500
commit2a9d5916a2acd0b468b9aa28977021fdd483e2aa (patch)
treea2df6258e213546a1807e15e45aa921ee69f192b /core/src/main
parent71f5dc2f7ce5b8183421586e6a77be65040a4dff (diff)
downloadkau-2a9d5916a2acd0b468b9aa28977021fdd483e2aa.tar.gz
kau-2a9d5916a2acd0b468b9aa28977021fdd483e2aa.tar.bz2
kau-2a9d5916a2acd0b468b9aa28977021fdd483e2aa.zip
Fix/searchview (#123)
* Use workaround for kclick * Add text cleared callback * Add bundle scene transition functions * Add applier * Remove need for explicit context * Revert
Diffstat (limited to 'core/src/main')
-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' />