Commit 049c9440 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Add getFirstCharacter function.

parent 753bb4b8
......@@ -5,6 +5,7 @@ import android.text.Spanned
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.widget.TextView
import chat.rocket.android.util.ifEmpty
object TextHelper {
......@@ -27,4 +28,15 @@ object TextHelper {
textView.movementMethod = LinkMovementMethod.getInstance()
textView.setText(spannableString, TextView.BufferType.SPANNABLE)
}
/**
* Returns the first character from a string.
*
* @param string The string to get its first character.
* @return The first character from a string.
*/
fun getFirstCharacter(string: String): String {
string.ifEmpty("?")
return string.substring(0, 1).toUpperCase()
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment