From bf136d76b81835a44a0d9038b2a87806247296e8 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 21 Aug 2017 14:39:00 -0700 Subject: Fix/kpref-inner-frame-size (#42) * Fix kpref item barriers * Revert and add text constraint --- core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt | 4 +++- core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'core/src') 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 -- cgit v1.2.3