diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-06 23:24:06 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-06 23:24:06 -0700 |
commit | 605a08c2e2e8634263d7626cf7471310add3acb2 (patch) | |
tree | 7652ecc94a4969688ce85ed94ab9233117d78a40 /app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt | |
parent | 067ea15188f20fa268255153e35c2df732fdffee (diff) | |
download | frost-605a08c2e2e8634263d7626cf7471310add3acb2.tar.gz frost-605a08c2e2e8634263d7626cf7471310add3acb2.tar.bz2 frost-605a08c2e2e8634263d7626cf7471310add3acb2.zip |
Preparing preferences
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt index 59600a4d..f13ec20d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt @@ -17,9 +17,9 @@ import com.pitchedapps.frost.facebook.FbTab private const val EXTRA_COOKIES = "extra_cookies" private const val ARG_URL = "arg_url" -fun Context.launchNewTask(clazz: Class<out Activity>, cookieList: ArrayList<CookieModel> = arrayListOf(), clearStack: Boolean = true) { +fun Context.launchNewTask(clazz: Class<out Activity>, cookieList: ArrayList<CookieModel> = arrayListOf()) { val intent = (Intent(this, clazz)) - if (clearStack && (clazz != LoginActivity::class.java)) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) + if (clazz != LoginActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) intent.putParcelableArrayListExtra(EXTRA_COOKIES, cookieList) startActivity(intent) if (this is Activity) finish() @@ -41,9 +41,15 @@ fun WebOverlayActivity.url(): String { return intent.extras?.getString(ARG_URL) ?: FbTab.FEED.url } -fun Activity.restart() { - finish() +fun Activity.restart(extras: ((Intent) -> Unit)? = null) { + val i = Intent(this, this::class.java) + i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) + extras?.invoke(i) + startActivity(i) overridePendingTransition(0, 0) //No transitions - startActivity(intent); + finish() overridePendingTransition(0, 0) } + +fun Int.toString(c: Context) = c.getString(this) +fun Int.toColor(c: Context) = ContextCompat.getColor(c, this)
\ No newline at end of file |