diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-19 12:58:44 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-19 12:58:44 -0700 |
commit | 94defc1ab5f9f987d5c1b14c91613364ce4ed1ba (patch) | |
tree | 41d8113315862bd61697057df5df717bedfe0a8e /library/src/main | |
parent | 9832aed0ea96312e59ed75c788a1b843f1947a7e (diff) | |
download | kau-94defc1ab5f9f987d5c1b14c91613364ce4ed1ba.tar.gz kau-94defc1ab5f9f987d5c1b14c91613364ce4ed1ba.tar.bz2 kau-94defc1ab5f9f987d5c1b14c91613364ce4ed1ba.zip |
Add thread logging
Diffstat (limited to 'library/src/main')
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/logging/KL.kt | 6 | ||||
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt | 12 |
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 |