diff options
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.kt | 20 |
1 files changed, 9 insertions, 11 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 db54282..0e4b5f1 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -35,25 +35,23 @@ inline fun <reified T : Activity> Context.startActivity( clearStack: Boolean = false, bundleBuilder: Bundle.() -> Unit = {}, intentBuilder: Intent.() -> Unit = {} -) { - val intent = Intent(this, T::class.java) - if (clearStack) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) - intent.intentBuilder() - val bundle = Bundle() - bundle.bundleBuilder() - startActivity(intent, bundle) - if (clearStack && this is Activity) finish() -} +) = startActivity(T::class.java, clearStack, bundleBuilder, intentBuilder) @Deprecated("Use reified generic instead of passing class", ReplaceWith("startActivity<T>(clearStack, bundleBuilder, intentBuilder)"), DeprecationLevel.WARNING) -inline fun <reified T : Activity> Context.startActivity( +inline fun <T : Activity> Context.startActivity( clazz: Class<T>, clearStack: Boolean = false, bundleBuilder: Bundle.() -> Unit = {}, intentBuilder: Intent.() -> Unit = {}) { - startActivity<T>(clearStack, bundleBuilder, intentBuilder) + val intent = Intent(this, clazz) + if (clearStack) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) + intent.intentBuilder() + val bundle = Bundle() + bundle.bundleBuilder() + startActivity(intent, bundle) + if (clearStack && this is Activity) finish() } |