More minSdk 21 cleanup

This commit is contained in:
TacoTheDank 2022-07-06 17:48:38 -04:00 committed by Stypox
parent 4ec9cbe379
commit 189c92affa
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
4 changed files with 5 additions and 26 deletions

View file

@ -12,7 +12,6 @@ import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.FloatRange
import androidx.core.animation.addListener
import androidx.core.view.ViewCompat
import androidx.core.view.isGone
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
@ -21,10 +20,6 @@ import org.schabi.newpipe.MainActivity
private const val TAG = "ViewUtils"
inline var View.backgroundTintListCompat: ColorStateList?
get() = ViewCompat.getBackgroundTintList(this)
set(value) = ViewCompat.setBackgroundTintList(this, value)
/**
* Animate the view.
*
@ -106,11 +101,11 @@ fun View.animateBackgroundColor(duration: Long, @ColorInt colorStart: Int, @Colo
viewPropertyAnimator.interpolator = FastOutSlowInInterpolator()
viewPropertyAnimator.duration = duration
viewPropertyAnimator.addUpdateListener { animation: ValueAnimator ->
backgroundTintListCompat = ColorStateList(empty, intArrayOf(animation.animatedValue as Int))
backgroundTintList = ColorStateList(empty, intArrayOf(animation.animatedValue as Int))
}
viewPropertyAnimator.addListener(
onCancel = { backgroundTintListCompat = ColorStateList(empty, intArrayOf(colorEnd)) },
onEnd = { backgroundTintListCompat = ColorStateList(empty, intArrayOf(colorEnd)) }
onCancel = { backgroundTintList = ColorStateList(empty, intArrayOf(colorEnd)) },
onEnd = { backgroundTintList = ColorStateList(empty, intArrayOf(colorEnd)) }
)
viewPropertyAnimator.start()
}