Skip to content

Commit 08543a5

Browse files
committed
Changed operator plus
1 parent 0df720c commit 08543a5

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

omegatypes/src/main/java/com/omega_r/libs/omegatypes/Text.kt

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ open class Text(protected val defaultTextStyle: TextStyle?) : Serializable {
7070
textView.text = getCharSequence(textView.context, textStyle)
7171
}
7272

73+
open operator fun plus(text: Text): Text {
74+
return TextBuilder.BuilderText(this) + text
75+
}
76+
77+
open operator fun plus(string: String): Text {
78+
return TextBuilder.BuilderText(this) + string
79+
}
80+
7381
override fun equals(other: Any?): Boolean {
7482
if (this === other) return true
7583
if (javaClass != other?.javaClass) return false
@@ -303,20 +311,6 @@ fun Context.toast(text: Text, duration: Int = Toast.LENGTH_SHORT, textStyle: Tex
303311
return Toast.makeText(this, text.getCharSequence(this, textStyle), duration).apply { show() }
304312
}
305313

306-
operator fun Text.plus(text: Text): Text {
307-
if (this is TextBuilder.BuilderText) {
308-
return this + text
309-
}
310-
return TextBuilder.BuilderText(this) + text
311-
}
312-
313-
operator fun Text.plus(string: String): Text {
314-
if (this is TextBuilder.BuilderText) {
315-
return this + string
316-
}
317-
return TextBuilder.BuilderText(this) + string
318-
}
319-
320314
fun String.toText(textStyle: TextStyle? = null) = Text.from(this, textStyle)
321315

322316
fun CharSequence.toText(textStyle: TextStyle? = null) = Text.from(this, textStyle)

omegatypes/src/main/java/com/omega_r/libs/omegatypes/TextBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ class TextBuilder(capacity: Int) : Serializable {
107107
return this
108108
}
109109

110-
operator fun plus(text: Text): Text {
110+
override operator fun plus(text: Text): Text {
111111
textBuilder.append(text)
112112
return this
113113
}
114114

115-
operator fun plus(string: String): Text{
115+
override operator fun plus(string: String): Text {
116116
textBuilder.append(string)
117117
return this
118118
}

0 commit comments

Comments
 (0)