From 957b3be0bd1eccc761ba8ca98255771b11198a69 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 21 Jun 2017 14:48:24 -0700 Subject: Improve activity restar --- library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'library/src/main') 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() -- cgit v1.2.3