Commit 58408b1f authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Only try to get from source when position with offset is valid

parent 2a94bfd5
......@@ -66,14 +66,18 @@ class ModelAdapterBuilder<T, VH : BaseViewHolder> internal constructor() {
}
if (source != null && bindModelViewWithPayload != null) {
val positionWithOffset = source.getPositionWithOffset(position)
if (source.hasItemAtInstant(source.getPositionWithOffset(position))) {
bindModelViewWithPayload!!(holder, position, source.getItemAtInstant(positionWithOffset), payload)
} else {
informLoadingData()
coroutineScope.launch {
bindModelViewWithPayload!!(holder, position, source.getItemAt(positionWithOffset), payload)
informLoadingDataFinished()
if(positionWithOffset >= 0) {
if (source.hasItemAtInstant(source.getPositionWithOffset(position))) {
bindModelViewWithPayload!!(holder, position, source.getItemAtInstant(positionWithOffset), payload)
} else {
informLoadingData()
coroutineScope.launch {
bindModelViewWithPayload!!(holder, position, source.getItemAt(positionWithOffset), payload)
informLoadingDataFinished()
}
}
} else {
bindNonModelViewWithPayload?.invoke(holder, position, payload)
}
} else if (source == null && bindNonModelViewWithPayload != null) bindNonModelViewWithPayload!!(holder, position, payload)
}
......
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