Delay restoring AppBar elevation on Android 5.0 (fixes #4311)

This commit is contained in:
arkon 2021-01-18 17:24:23 -05:00
parent 1a5858e99b
commit 837d8f5f30

View file

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.widget
import android.animation.ObjectAnimator
import android.animation.StateListAnimator
import android.content.Context
import android.os.Build
import android.util.AttributeSet
import com.google.android.material.R
import com.google.android.material.appbar.AppBarLayout
@ -19,6 +20,15 @@ class ElevationAppBarLayout @JvmOverloads constructor(
}
fun enableElevation(liftOnScroll: Boolean) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
// Delay to avoid crash
post { setElevation(liftOnScroll) }
} else {
setElevation(liftOnScroll)
}
}
private fun setElevation(liftOnScroll: Boolean) {
stateListAnimator = origStateAnimator
isLiftOnScroll = liftOnScroll
}