diff options
-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() |