aboutsummaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-19 12:58:44 -0700
committerAllan Wang <me@allanwang.ca>2017-06-19 12:58:44 -0700
commit94defc1ab5f9f987d5c1b14c91613364ce4ed1ba (patch)
tree41d8113315862bd61697057df5df717bedfe0a8e /library
parent9832aed0ea96312e59ed75c788a1b843f1947a7e (diff)
downloadkau-94defc1ab5f9f987d5c1b14c91613364ce4ed1ba.tar.gz
kau-94defc1ab5f9f987d5c1b14c91613364ce4ed1ba.tar.bz2
kau-94defc1ab5f9f987d5c1b14c91613364ce4ed1ba.zip
Add thread logging
Diffstat (limited to 'library')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/logging/KL.kt6
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt12
2 files changed, 17 insertions, 1 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/logging/KL.kt b/library/src/main/kotlin/ca/allanwang/kau/logging/KL.kt
new file mode 100644
index 0000000..4fa3360
--- /dev/null
+++ b/library/src/main/kotlin/ca/allanwang/kau/logging/KL.kt
@@ -0,0 +1,6 @@
+package ca.allanwang.kau.logging
+
+/**
+ * Created by Allan Wang on 2017-06-19.
+ */
+object KL : TimberLogger("KAU") \ No newline at end of file
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt
index e00891d..642c29c 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt
@@ -2,6 +2,8 @@ package ca.allanwang.kau.utils
import android.content.res.Resources
import android.os.Build
+import android.os.Looper
+import ca.allanwang.kau.logging.KL
/**
* Created by Allan Wang on 2017-05-28.
@@ -17,4 +19,12 @@ val buildIsLollipopAndUp: Boolean
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
val buildIsMarshmallowAndUp: Boolean
- get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M \ No newline at end of file
+ get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
+
+/**
+ * Log whether current state is in the main thread
+ */
+fun checkThread(id: Int) {
+ val status = if (Looper.myLooper() == Looper.getMainLooper()) "is" else "is not"
+ KL.d("$id $status in the main thread")
+} \ No newline at end of file