Skip to content

Commit

Permalink
feat: renderable items now also accepts nullable stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gotev committed Mar 23, 2021
1 parent 552f14d commit 67ce9d9
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,24 @@ inline fun <T> Array<T>.mapToAdapterItems(transform: (T) -> AdapterItem<*>?): Ad
class RenderableItems internal constructor() {
internal val items = ArrayList<AdapterItem<*>>()

operator fun AdapterItem<*>.unaryPlus() {
items.add(this)
operator fun AdapterItem<*>?.unaryPlus() {
if (this != null) { items.add(this) }
}

operator fun Array<out AdapterItem<*>>.unaryPlus() {
items.addAll(this)
operator fun Array<out AdapterItem<*>>?.unaryPlus() {
if (this != null) { items.addAll(this) }
}

operator fun ArrayList<out AdapterItem<*>>.unaryPlus() {
items.addAll(this)
operator fun ArrayList<out AdapterItem<*>>?.unaryPlus() {
if (this != null) { items.addAll(this) }
}

operator fun List<AdapterItem<*>>.unaryPlus() {
items.addAll(this)
operator fun List<AdapterItem<*>>?.unaryPlus() {
if (this != null) { items.addAll(this) }
}

operator fun RenderableItems.unaryPlus() {
this@RenderableItems.items.addAll(items)
operator fun RenderableItems?.unaryPlus() {
if (this != null) { this@RenderableItems.items.addAll(items) }
}

fun toAdapter(): RecyclerAdapter {
Expand Down

0 comments on commit 67ce9d9

Please sign in to comment.