@file:JvmName("RecyclerViewEx")
package com.adealink.weparty.commonui.ext

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SimpleItemAnimator

fun RecyclerView.disableItemAnimation() {
    val animator = this.itemAnimator
    if (animator is SimpleItemAnimator) {
        animator.supportsChangeAnimations = false
    }
    animator?.apply {
        addDuration = 0
        removeDuration = 0
        moveDuration = 0
        changeDuration = 0
    }
}

fun RecyclerView.disableItemChangeAnimation() {
    val animator = this.itemAnimator
    if (animator is SimpleItemAnimator) {
        animator.supportsChangeAnimations = false
    } else {
        animator?.apply {
            changeDuration = 0
        }
    }
}

fun RecyclerView.setOverScrollModeToNever() {
    overScrollMode = View.OVER_SCROLL_NEVER
}
