Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. private fun span(s: CharSequence, o: Any) = (if (s is String) SpannableString(s) else s as? SpannableString
  2. ?: SpannableString("")).apply { setSpan(o, 0, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) }
  3.  
  4. operator fun SpannableString.plus(s: SpannableString) = SpannableString(TextUtils.concat(this, s))
  5.  
  6. fun color(color: Int, s: CharSequence) = span(s, ForegroundColorSpan(color))
  7.  
  8. "Top trending position: " + color(Color.RED, poll.topTrendingPosition.toString())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement