File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed
app/src/main/java/omega_r/com/omegatypesexample
java/com/omega_r/libs/omegatypes Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class MainActivity : BaseActivity() {
1616 override fun onCreate (savedInstanceState : Bundle ? ) {
1717 super .onCreate(savedInstanceState)
1818 setContentView(R .layout.activity_main)
19- val text = Text .from(" test " ) + Text .from(R .string.hello_world, textStyle = TextStyle .bold())
19+ val text = Text .from(" test " ) + Text .from(R .string.hello_world, Text .from( R .string.app_name), textStyle = TextStyle .bold())
2020 text.applyTo(exampleTextView) // or exampleTextView.setText(text)
2121 val image = Image .from(" https://avatars1.githubusercontent.com/u/28600571" )
2222
Original file line number Diff line number Diff line change @@ -142,6 +142,16 @@ open class Text(protected val defaultTextStyle: TextStyle? ) : Serializable {
142142 override fun isEmpty (): Boolean = stringRes <= 0
143143
144144 override fun getString (context : Context ): String {
145+ if (formatArgs.firstOrNull { it is Text } != null ) {
146+ val list = formatArgs.map {
147+ when (it) {
148+ is Text -> it.getString(context)
149+ else -> it
150+ }
151+ }
152+ return context.getString(stringRes, * list.toTypedArray())
153+ }
154+
145155 return context.getString(stringRes, * formatArgs)
146156 }
147157
Original file line number Diff line number Diff line change 11<resources >
22 <string name =" app_name" >lib</string >
3- <string name =" hello_world" >Hello world</string >
3+ <string name =" hello_world" >Hello world %s super </string >
44</resources >
You can’t perform that action at this time.
0 commit comments