Skip to content
Snippets Groups Projects
Commit d1642750 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixed minor bug

parent a5116c7d
Branches
Tags
No related merge requests found
......@@ -30,22 +30,6 @@ import java.util.regex.Pattern
object SpanFormatter {
private val FORMAT_SEQUENCE = Pattern.compile("%([0-9]+\\$|<?)([^a-zA-z%]*)([[a-zA-Z%]&&[^tT]]|[tT][a-zA-Z])")
/**
* Version of [String.format] that works on [Spanned] strings to preserve rich text formatting.
* Both the `format` as well as any `%s args` can be Spanned and will have their formatting preserved.
* Due to the way [Spannable]s work, any argument's spans will can only be included **once** in the result.
* Any duplicates will appear as text only.
*
* @param format the format string (see [java.util.Formatter.format])
* @param args the list of arguments passed to the formatter. If there are
* more arguments than required by `format`,
* additional arguments are ignored.
* @return the formatted string (with spans).
*/
fun format(format: CharSequence, vararg args: Any): SpannedString {
return format(Locale.getDefault(), format, *args)
}
/**
* Version of [String.format] that works on [Spanned] strings to preserve rich text formatting.
* Both the `format` as well as any `%s args` can be Spanned and will have their formatting preserved.
......@@ -58,7 +42,8 @@ object SpanFormatter {
* @return the formatted string (with spans).
* @see String.format
*/
fun format(locale: Locale, format: CharSequence, vararg args: Any): SpannedString {
fun format(format: CharSequence, vararg args: Any?,
locale: Locale = Locale.getDefault()): SpannedString {
val out = SpannableStringBuilder(format)
var i = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment