Skip to content

Instantly share code, notes, and snippets.

Looking for a job

Vladimir Kondenko

Looking for a job
Block or report user

Report or block Kondenko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Kondenko / DiffUtilDelegate.kt
Last active Jun 24, 2019
A delegate to update RecycletView's adapter data with DiffUtil
View DiffUtilDelegate.kt
class DiffUtilDelegate<T, VH : RecyclerView.ViewHolder, A : RecyclerView.Adapter<VH>>(
initialValue: List<T>,
private val callbackFactory: (List<T>, List<T>) -> DiffUtil.Callback =
{ old, new -> SimpleCallback(old, new) }
) {
private var currentValue: List<T> = initialValue
operator fun setValue(thisRef: A?, property: KProperty<*>, value: List<T>) {
val callback = callbackFactory(currentValue, value)
Kondenko / FlowExtensions.kt
Created Jun 15, 2019
Kotlin Flow Extensions
View FlowExtensions.kt
fun <T> Flow<T>.bufferList(capacity: Int): Flow<List<T>> {
require(capacity > 0) { "Buffer size should be positive, but was $capacity" }
var buffer = listOf<T>()
return transform { value ->
if (buffer.size == capacity) emit(buffer)
else buffer = buffer + value
You can’t perform that action at this time.