diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-21 14:48:24 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-21 14:48:24 -0700 |
commit | 957b3be0bd1eccc761ba8ca98255771b11198a69 (patch) | |
tree | ecc7efc42778ed23b39d7ba207ddd4dd26ab9329 /library/src/main/kotlin/ca | |
parent | 24a0d564d3a9d5c206b0299b690653ec49d63aca (diff) | |
download | kau-957b3be0bd1eccc761ba8ca98255771b11198a69.tar.gz kau-957b3be0bd1eccc761ba8ca98255771b11198a69.tar.bz2 kau-957b3be0bd1eccc761ba8ca98255771b11198a69.zip |
Improve activity restar
Diffstat (limited to 'library/src/main/kotlin/ca')
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt index 1499c9f..b293dc1 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -22,10 +22,11 @@ import java.util.* /** * Created by Allan Wang on 2017-06-03. */ -fun Activity.restart(extras: ((Intent) -> Unit)? = null) { +fun Activity.restart(action: Intent.() -> Unit = {}) { val i = Intent(this, this::class.java) i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) - extras?.invoke(i) + i.putExtras(intent.extras) + i.action() startActivity(i) overridePendingTransition(0, 0) //No transitions finish() |