aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt5
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt4
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