aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-24 01:17:31 -0500
committerGitHub <noreply@github.com>2018-12-24 01:17:31 -0500
commitfb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b (patch)
treecc6d67461b6caa256043b9482f7646831d528a08 /core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt
parenta380adea1052d39f23c9c4d432a9380ce347d6c4 (diff)
downloadkau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.gz
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.bz2
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.zip
Enhancement/ktlint (#179)
* Add spotless dependency * Apply ktlint * Add license headers
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt58
1 files changed, 42 insertions, 16 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 d628214..314ca60 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.utils
import android.annotation.SuppressLint
@@ -5,9 +20,9 @@ import android.app.Activity
import android.app.ActivityOptions
import android.content.Context
import android.os.Bundle
-import androidx.annotation.AnimRes
import android.util.Pair
import android.view.View
+import androidx.annotation.AnimRes
import ca.allanwang.kau.R
/**
@@ -36,9 +51,9 @@ fun Bundle.withSceneTransitionAnimation(context: Context) {
* create a scene transition animation
*/
fun Bundle.withSceneTransitionAnimation(parent: View, data: Map<Int, String>) =
- withSceneTransitionAnimation(parent.context, data.mapKeys { (id, _) ->
- parent.findViewById<View>(id)
- })
+ withSceneTransitionAnimation(parent.context, data.mapKeys { (id, _) ->
+ parent.findViewById<View>(id)
+ })
/**
* Given a mapping of views to tags,
@@ -48,22 +63,33 @@ fun Bundle.withSceneTransitionAnimation(parent: View, data: Map<Int, String>) =
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())
+ *data.map { (view, tag) -> Pair(view, tag) }.toTypedArray()
+ )
putAll(options.toBundle())
}
-fun Bundle.withCustomAnimation(context: Context,
- @AnimRes enterResId: Int,
- @AnimRes exitResId: Int) {
- this with ActivityOptions.makeCustomAnimation(context,
- enterResId, exitResId).toBundle()
+fun Bundle.withCustomAnimation(
+ context: Context,
+ @AnimRes enterResId: Int,
+ @AnimRes exitResId: Int
+) {
+ this with ActivityOptions.makeCustomAnimation(
+ context,
+ enterResId, exitResId
+ ).toBundle()
}
-fun Bundle.withSlideIn(context: Context) = withCustomAnimation(context,
- R.anim.kau_slide_in_right, R.anim.kau_fade_out)
+fun Bundle.withSlideIn(context: Context) = withCustomAnimation(
+ context,
+ R.anim.kau_slide_in_right, R.anim.kau_fade_out
+)
-fun Bundle.withSlideOut(context: Context) = withCustomAnimation(context,
- R.anim.kau_fade_in, R.anim.kau_slide_out_right_top)
+fun Bundle.withSlideOut(context: Context) = withCustomAnimation(
+ context,
+ R.anim.kau_fade_in, R.anim.kau_slide_out_right_top
+)
-fun Bundle.withFade(context: Context) = withCustomAnimation(context,
- android.R.anim.fade_in, android.R.anim.fade_out) \ No newline at end of file
+fun Bundle.withFade(context: Context) = withCustomAnimation(
+ context,
+ android.R.anim.fade_in, android.R.anim.fade_out
+)