Skip to content

Commit 50e0db0

Browse files
committed
Add JvmOverloads in Image
Add extension for Text operator plus with null
1 parent 7ce4c69 commit 50e0db0

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ import java.io.*
1515

1616
open class Image : Serializable {
1717

18-
open fun preload(context: Context) {
19-
// nothing
20-
}
21-
18+
@JvmOverloads
2219
open fun applyImage(imageView: ImageView, placeholderResId: Int = 0) {
2320
if (placeholderResId == 0) {
2421
imageView.setImageDrawable(null)
@@ -27,6 +24,7 @@ open class Image : Serializable {
2724
}
2825
}
2926

27+
@JvmOverloads
3028
open fun applyBackground(view: View, placeholderResId: Int = 0) {
3129
if (placeholderResId == 0) {
3230
view.setBackgroundResource(placeholderResId)
@@ -36,6 +34,7 @@ open class Image : Serializable {
3634
}
3735

3836

37+
@JvmOverloads
3938
@Throws(IOException::class)
4039
open fun getStream(context: Context,
4140
compressFormat: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG, quality: Int = 100): InputStream {
@@ -44,6 +43,10 @@ open class Image : Serializable {
4443
}
4544
}
4645

46+
open fun preload(context: Context) {
47+
// nothing
48+
}
49+
4750
protected fun applyBackground(view: View, background: Drawable?) {
4851
Image.applyBackground(view, background)
4952
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,14 @@ operator fun Text?.plus(text: Text?): Text? {
329329
}
330330
}
331331

332+
operator fun Text?.plus(string: String?): Text? {
333+
return when {
334+
this == null -> string?.let { Text.from(string) }
335+
string == null -> this
336+
else -> this + string
337+
}
338+
}
339+
332340
operator fun Text?.plus(textStyle: TextStyle?): Text? {
333341
return this?.let { this + textStyle }
334342
}

0 commit comments

Comments
 (0)