Browse Source

Add custom string separators

merge-requests/1454/head
Robert Stone 4 years ago
parent
commit
ad8abfc444
  1. 25
      application/vlc-android/src/org/videolan/vlc/util/TextUtils.kt

25
application/vlc-android/src/org/videolan/vlc/util/TextUtils.kt

@ -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

Loading…
Cancel
Save