aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-09-24 16:56:11 -0400
committerGitHub <noreply@github.com>2017-09-24 16:56:11 -0400
commit1edb6e1ac1297f6feb229d8f89e07a88de1ae2e9 (patch)
tree5009d1486f2e1ccc0ddff88bbf0ad51b9d20e1e7 /core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
parentc465bd64a7da087447659b83ed515d87ee8d342f (diff)
downloadkau-1edb6e1ac1297f6feb229d8f89e07a88de1ae2e9.tar.gz
kau-1edb6e1ac1297f6feb229d8f89e07a88de1ae2e9.tar.bz2
kau-1edb6e1ac1297f6feb229d8f89e07a88de1ae2e9.zip
v3.4.3 (#65)3.4.3
* fix/mediapicker (#50) * Bring all glide request managers to one instance * Switch to test implementation * Check if parent is null for searchview * Ensure open close runs on ui thread * Make glide contract internal * Update changelog * Update version Update changelog for previous prs * v3.4.1 (#63) * Check browser intent before launching (#54) * Update changelog * fix/misc (#55) * Add kapt plugin * Fix kau vector * Debug lintRelease * Revert debug * Update dependencies * Check context finishing state before showing dialog (#61) * Keep copy of shared pref rather than application context (#60) * Keep copy of shared pref rather than application context * Add back preference name * Add resolver checks (#62) Squashed commit of the following: commit 7fe57d4ab1dbfe8bfb4d4a15bd0fbf636da491fa Author: Allan Wang <me@allanwang.ca> Date: Sat Sep 23 15:25:18 2017 -0400 Add missing quote commit ffc3ac99248c2250a7f14ef709f37d787cbe0d83 Author: Allan Wang <me@allanwang.ca> Date: Sat Sep 23 15:20:54 2017 -0400 Update changelog Update gradle Update version name * Fix bundle NPE for activity creation Update changelog * Feature/kpref time picker (#64) * Init kpref time builder and open up other builders * Enable self refresh * Add readme * Update changelog * Update readme
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt20
1 files changed, 11 insertions, 9 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
index a72c7dd..0664dc6 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
@@ -43,9 +43,9 @@ fun Context.startActivity(
intentBuilder: Intent.() -> Unit = {}) {
val intent = Intent(this, clazz)
if (clearStack) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
- val fullBundle = if (transition && this is Activity && buildIsLollipopAndUp)
- ActivityOptions.makeSceneTransitionAnimation(this).toBundle()
- else Bundle()
+ val fullBundle = Bundle()
+ if (transition && this is Activity && buildIsLollipopAndUp)
+ fullBundle.with(ActivityOptions.makeSceneTransitionAnimation(this).toBundle())
if (transition && this !is Activity) KL.d("Cannot make scene transition when context is not an instance of an Activity")
if (bundle != null) fullBundle.putAll(bundle)
intent.intentBuilder()
@@ -57,9 +57,10 @@ fun Context.startActivity(
* Bring in activity from the right
*/
fun Context.startActivitySlideIn(clazz: Class<out Activity>, clearStack: Boolean = false, intentBuilder: Intent.() -> Unit = {}, bundleBuilder: Bundle.() -> Unit = {}) {
- val bundle = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.kau_slide_in_right, R.anim.kau_fade_out).toBundle()
- bundle.bundleBuilder()
- startActivity(clazz, clearStack, intentBuilder = intentBuilder, bundle = bundle)
+ val fullBundle = Bundle()
+ fullBundle.with(ActivityOptionsCompat.makeCustomAnimation(this, R.anim.kau_slide_in_right, R.anim.kau_fade_out).toBundle())
+ fullBundle.bundleBuilder()
+ startActivity(clazz, clearStack, intentBuilder = intentBuilder, bundle = if (fullBundle.isEmpty) null else fullBundle)
}
/**
@@ -69,9 +70,10 @@ fun Context.startActivitySlideIn(clazz: Class<out Activity>, clearStack: Boolean
* Consequently, the stack will be cleared by default
*/
fun Context.startActivitySlideOut(clazz: Class<out Activity>, clearStack: Boolean = true, intentBuilder: Intent.() -> Unit = {}, bundleBuilder: Bundle.() -> Unit = {}) {
- val bundle = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.kau_fade_in, R.anim.kau_slide_out_right_top).toBundle()
- bundle.bundleBuilder()
- startActivity(clazz, clearStack, intentBuilder = intentBuilder, bundle = bundle)
+ val fullBundle = Bundle()
+ fullBundle.with(ActivityOptionsCompat.makeCustomAnimation(this, R.anim.kau_fade_in, R.anim.kau_slide_out_right_top).toBundle())
+ fullBundle.bundleBuilder()
+ startActivity(clazz, clearStack, intentBuilder = intentBuilder, bundle = if (fullBundle.isEmpty) null else fullBundle)
}
fun Context.startPlayStoreLink(@StringRes packageIdRes: Int) = startPlayStoreLink(string(packageIdRes))