aboutsummaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-06 17:12:06 -0500
committerAllan Wang <me@allanwang.ca>2018-01-06 17:12:06 -0500
commit401e8db1e6d34f3fcb3b1b96d225f7aa6c17d292 (patch)
tree2804109d4a2411c422d74e6939c64bbd4d245d77 /core/src/main
parent8a88dc077466cff9c5f2daf9185142b311f45270 (diff)
downloadkau-401e8db1e6d34f3fcb3b1b96d225f7aa6c17d292.tar.gz
kau-401e8db1e6d34f3fcb3b1b96d225f7aa6c17d292.tar.bz2
kau-401e8db1e6d34f3fcb3b1b96d225f7aa6c17d292.zip
Do not require reified generics for deprecated method3.6.2
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt17
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt20
2 files changed, 17 insertions, 20 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt
index 3484353..f8643db 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt
@@ -31,23 +31,22 @@ annotation class KauActivity
inline fun <reified T : Activity> Activity.startActivityForResult(
requestCode: Int,
bundleBuilder: Bundle.() -> Unit = {},
- intentBuilder: Intent.() -> Unit = {}) {
- val intent = Intent(this, T::class.java)
- intent.intentBuilder()
- val bundle = Bundle()
- bundle.bundleBuilder()
- startActivityForResult(intent, requestCode, bundle)
-}
+ intentBuilder: Intent.() -> Unit = {}
+) = startActivityForResult(T::class.java, requestCode, bundleBuilder, intentBuilder)
@Deprecated("Use reified generic instead of passing class",
ReplaceWith("startActivityForResult<T>(requestCode, bundleBuilder, intentBuilder)"),
DeprecationLevel.WARNING)
-inline fun <reified T : Activity> Activity.startActivityForResult(
+inline fun <T : Activity> Activity.startActivityForResult(
clazz: Class<T>,
requestCode: Int,
bundleBuilder: Bundle.() -> Unit = {},
intentBuilder: Intent.() -> Unit = {}) {
- startActivityForResult<T>(requestCode, bundleBuilder, intentBuilder)
+ val intent = Intent(this, clazz)
+ intent.intentBuilder()
+ val bundle = Bundle()
+ bundle.bundleBuilder()
+ startActivityForResult(intent, requestCode, bundle)
}
/**
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()
}