Skip to content

Commit 98c8583

Browse files
committed
Add partName
1 parent 4108892 commit 98c8583

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

extensionslib/src/main/java/com/omega_r/libs/extensions/string/StringExtensions.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,24 @@ fun String.fromHtml(): Spanned {
3535
} else {
3636
Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY)
3737
}
38+
}
39+
40+
fun String?.addPartName(partName: String?): String? {
41+
var result = this
42+
if (!partName.isNullOrBlank()) {
43+
if (!result.isNullOrEmpty()) {
44+
result += " $partName"
45+
} else {
46+
result = partName
47+
}
48+
}
49+
return result
50+
}
51+
52+
fun String?.addPartNames(vararg partNames: String?): String? {
53+
var result: String? = this
54+
for (partName in partNames) {
55+
result = result.addPartName(partName)
56+
}
57+
return result
3858
}

0 commit comments

Comments
 (0)