Skip to content
Snippets Groups Projects
Commit ad8abfc4 authored by Robert Stone's avatar Robert Stone
Browse files

Add custom string separators

parent 71baada7
No related branches found
No related tags found
1 merge request!1443Android Auto: Play As Audio Fix and Code Clean-up
......@@ -38,18 +38,35 @@ object TextUtils {
* Create a string separated by the common [separator]
*
* @param pieces the strings to join
* @return a string containing all the [pieces] if they are not blanked, spearated by the [separator]
* @return a string containing all the [pieces] if they are not blanked, separated by the [separator]
*/
@JvmName("separatedStringArgs")
fun separatedString(vararg pieces: String?) = separatedString(arrayOf(*pieces))
fun separatedString(vararg pieces: String?) = separatedString(this.separator, arrayOf(*pieces))
/**
* Create a string separated by the common [separator]
*
* @param pieces the strings to join in an [Array]
* @return a string containing all the [pieces] if they are not blanked, spearated by the [separator]
* @return a string containing all the [pieces] if they are not blanked, separated by the [separator]
*/
fun separatedString(pieces: Array<String?>) = pieces.filter { it?.isNotBlank() == true }.joinToString(separator = " $separator ")
fun separatedString(pieces: Array<String?>) = separatedString(this.separator, pieces)
/**
* Create a string separated by a custom [separator]
*
* @param pieces the strings to join
* @return a string containing all the [pieces] if they are not blanked, separated by [separator]
*/
@JvmName("separatedStringArgs")
fun separatedString(separator: Char, vararg pieces: String?) = separatedString(separator, arrayOf(*pieces))
/**
* Create a string separated by a custom [separator]
*
* @param pieces the strings to join in an [Array]
* @return a string containing all the [pieces] if they are not blanked, separated by [separator]
*/
fun separatedString(separator: Char, pieces: Array<String?>) = pieces.filter { it?.isNotBlank() == true }.joinToString(separator = " $separator ")
/**
* Formats the chapter title by prepending "Chapter:" if the current title is made of only non alpha chars
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment