aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca
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/kotlin/ca
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/kotlin/ca')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt26
1 files changed, 25 insertions, 1 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,