aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt4
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt6
2 files changed, 8 insertions, 2 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt
index 889f347..1eeac1a 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt
@@ -18,4 +18,6 @@ const val KAU_ALL = KAU_HORIZONTAL or KAU_VERTICAL
const val KAU_COLLAPSED = 0
const val KAU_COLLAPSING = 1
const val KAU_EXPANDING = 2
-const val KAU_EXPANDED = 3 \ No newline at end of file
+const val KAU_EXPANDED = 3
+
+const val KAU_ELLIPSIS = '\u2026' \ No newline at end of file
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 cdb49ea..50a3c29 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt
@@ -118,4 +118,8 @@ fun postDelayed(delay: Long, action: () -> Unit) {
inline val kauIsMainThread: Boolean
get() = Looper.myLooper() == Looper.getMainLooper()
-class KauException(message: String) : RuntimeException(message) \ No newline at end of file
+class KauException(message: String) : RuntimeException(message)
+
+fun String.withMaxLength(n: Int): String =
+ if (length <= n) this
+ else substring(0, n-1) + KAU_ELLIPSIS \ No newline at end of file