Skip to content

Commit 67ce9d9

Browse files
committed
feat: renderable items now also accepts nullable stuff
1 parent 552f14d commit 67ce9d9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

recycleradapter-extensions/src/main/java/net/gotev/recycleradapter/ext/DeclarativeExtensions.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,24 @@ inline fun <T> Array<T>.mapToAdapterItems(transform: (T) -> AdapterItem<*>?): Ad
7979
class RenderableItems internal constructor() {
8080
internal val items = ArrayList<AdapterItem<*>>()
8181

82-
operator fun AdapterItem<*>.unaryPlus() {
83-
items.add(this)
82+
operator fun AdapterItem<*>?.unaryPlus() {
83+
if (this != null) { items.add(this) }
8484
}
8585

86-
operator fun Array<out AdapterItem<*>>.unaryPlus() {
87-
items.addAll(this)
86+
operator fun Array<out AdapterItem<*>>?.unaryPlus() {
87+
if (this != null) { items.addAll(this) }
8888
}
8989

90-
operator fun ArrayList<out AdapterItem<*>>.unaryPlus() {
91-
items.addAll(this)
90+
operator fun ArrayList<out AdapterItem<*>>?.unaryPlus() {
91+
if (this != null) { items.addAll(this) }
9292
}
9393

94-
operator fun List<AdapterItem<*>>.unaryPlus() {
95-
items.addAll(this)
94+
operator fun List<AdapterItem<*>>?.unaryPlus() {
95+
if (this != null) { items.addAll(this) }
9696
}
9797

98-
operator fun RenderableItems.unaryPlus() {
99-
this@RenderableItems.items.addAll(items)
98+
operator fun RenderableItems?.unaryPlus() {
99+
if (this != null) { this@RenderableItems.items.addAll(items) }
100100
}
101101

102102
fun toAdapter(): RecyclerAdapter {

0 commit comments

Comments
 (0)