Commit 2a94bfd5 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Extract val

parent f5226315
......@@ -46,12 +46,13 @@ class ModelAdapterBuilder<T, VH : BaseViewHolder> internal constructor() {
it.hasItemAt(it.getPositionWithOffset(position))
}
if (source != null) {
if (source.hasItemAtInstant(source.getPositionWithOffset(position))) {
bindModelView(holder, position, source.getItemAtInstant(source.getPositionWithOffset(position)))
val positionWithOffset = source.getPositionWithOffset(position)
if (source.hasItemAtInstant(positionWithOffset)) {
bindModelView(holder, position, source.getItemAtInstant(positionWithOffset))
} else {
informLoadingData()
coroutineScope.launch {
bindModelView(holder, position, source.getItemAt(source.getPositionWithOffset(position)))
bindModelView(holder, position, source.getItemAt(positionWithOffset))
informLoadingDataFinished()
}
}
......@@ -64,12 +65,13 @@ class ModelAdapterBuilder<T, VH : BaseViewHolder> internal constructor() {
it.hasItemAt(it.getPositionWithOffset(position))
}
if (source != null && bindModelViewWithPayload != null) {
val positionWithOffset = source.getPositionWithOffset(position)
if (source.hasItemAtInstant(source.getPositionWithOffset(position))) {
bindModelViewWithPayload!!(holder, position, source.getItemAtInstant(source.getPositionWithOffset(position)), payload)
bindModelViewWithPayload!!(holder, position, source.getItemAtInstant(positionWithOffset), payload)
} else {
informLoadingData()
coroutineScope.launch {
bindModelViewWithPayload!!(holder, position, source.getItemAt(source.getPositionWithOffset(position)), payload)
bindModelViewWithPayload!!(holder, position, source.getItemAt(positionWithOffset), payload)
informLoadingDataFinished()
}
}
......@@ -217,7 +219,7 @@ open class ListDataSource<T>(val list: List<T>,
}
override fun hasItemAtInstant(position: Int): Boolean {
return list.size > (position)
return list.size > position
}
override fun getItemAtInstant(position: Int): T {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment