This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Value | * | Example | |
---|---|---|---|
WIDE | Kotlin, Java, and Xml | Use list formatting with full word (no abbrevations) | |
SHORT | Kotlin, Java, & Xml | Use list formatting of typical length | |
NARROW | Kotlin, Java, Xml | Use list formatting of shortest possible length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Value | example | * | |
---|---|---|---|
AND | Kotlin, Java, and Xml | Conjunction formatting | |
OR | Kotlin, Java, or Xml | disjunction formatting | |
UNITS | 1 cm, 2kg, 3km | used for formatting list of values with units |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequiresApi(Build.VERSION_CODES.TIRAMISU) | |
fun List<String?>?.formatter(type: ListFormatter.Type, width: Width): String { | |
var formattedValue = "" | |
try { | |
ListFormatter.getInstance() | |
val formatter = ListFormatter.getInstance(Locale.getDefault(), type, width) | |
formattedValue = formatter.format(this) | |
} catch (e: Exception) { | |
Log.d("ListFormatter", "error in formatting list") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Locale (region) | Result of formatting | * | |
---|---|---|---|
ja_JP ( japan ) | Kotlin、Java、Xml | separator itself changed | |
en_US ( US ) | Kotlin, Java, and Xml | separator before conjunction | |
en_GB ( UK ) | Kotlin, Java and Xml | separator not present before conjunction | |
de_DE ( Germany ) | Kotlin, Java und Xml | conjunction word | |
zh_TW ( Taiwan ) | Kotlin、Java和Xml | conjunction word and spacing in between | |
ko_KR ( Korea ) | Kotlin, Java 및 Xml | conjunction word and spacing in between |