diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-12 23:07:10 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-08-30 12:24:19 -0400 |
commit | 5c45c832df044c400a76abad16a000a59d0bf54c (patch) | |
tree | 5cb6b67321eaecd09b8b5a36839b3bdd2f57d6a7 /core/src/main | |
parent | 83f9324184f0cf6ccea29888f3d3e91f95e52971 (diff) | |
download | kau-5c45c832df044c400a76abad16a000a59d0bf54c.tar.gz kau-5c45c832df044c400a76abad16a000a59d0bf54c.tar.bz2 kau-5c45c832df044c400a76abad16a000a59d0bf54c.zip |
Add more functions
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt | 5 | ||||
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt | 4 |
2 files changed, 9 insertions, 0 deletions
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 20cec73..d561c8a 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -90,6 +90,11 @@ fun Context.startLink(vararg url: String?) { startActivity(browserIntent) } +fun Context.startLink(@StringRes url: Int) { + val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(string(url))) + startActivity(browserIntent) +} + //Toast helpers inline fun View.toast(@StringRes id: Int, duration: Int = Toast.LENGTH_LONG) = context.toast(id, duration) diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt index 9e0ad75..cdb49ea 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt @@ -7,6 +7,7 @@ import android.graphics.Canvas import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable import android.os.Handler +import android.os.Looper import android.support.annotation.IntRange import ca.allanwang.kau.R import java.math.RoundingMode @@ -114,4 +115,7 @@ fun postDelayed(delay: Long, action: () -> Unit) { Handler().postDelayed(action, delay) } +inline val kauIsMainThread: Boolean + get() = Looper.myLooper() == Looper.getMainLooper() + class KauException(message: String) : RuntimeException(message)
\ No newline at end of file |