From 837d8f5f3002fb628acd3ece6352fed190d14a15 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 18 Jan 2021 17:24:23 -0500 Subject: [PATCH] Delay restoring AppBar elevation on Android 5.0 (fixes #4311) --- .../kanade/tachiyomi/widget/ElevationAppBarLayout.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt index e64e793a36..66057589fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt @@ -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 }