From d6296fa6fb95443ce59a3d8f35303be7366d7b00 Mon Sep 17 00:00:00 2001 From: cgspine Date: Thu, 22 Nov 2018 14:52:44 +0800 Subject: [PATCH] bugfix: Swipe back will flash at the end. #443 --- .../qmui/layout/QMUILayoutHelper.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/qmui/src/main/java/com/qmuiteam/qmui/layout/QMUILayoutHelper.java b/qmui/src/main/java/com/qmuiteam/qmui/layout/QMUILayoutHelper.java index f33f64aeb..728a3c275 100644 --- a/qmui/src/main/java/com/qmuiteam/qmui/layout/QMUILayoutHelper.java +++ b/qmui/src/main/java/com/qmuiteam/qmui/layout/QMUILayoutHelper.java @@ -80,7 +80,7 @@ public class QMUILayoutHelper implements IQMUILayout { // shadow private boolean mIsShowBorderOnlyBeforeL = true; private int mShadowElevation = 0; - private float mShadowAlpha = 0f; + private float mShadowAlpha; private int mShadowColor = Color.BLACK; // outline inset @@ -280,15 +280,15 @@ public void setShadowAlpha(float shadowAlpha) { @Override public void setShadowColor(int shadowColor) { - if(mShadowColor == shadowColor){ + if (mShadowColor == shadowColor) { return; } mShadowColor = shadowColor; setShadowColorInner(mShadowColor); } - private void setShadowColorInner(int shadowColor){ - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){ + private void setShadowColorInner(int shadowColor) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { View owner = mOwner.get(); if (owner == null) { return; @@ -358,7 +358,7 @@ public void setRadiusAndShadow(int radius, @IQMUILayout.HideRadiusSide int hideR @Override public void setRadiusAndShadow(int radius, int hideRadiusSide, int shadowElevation, int shadowColor, float shadowAlpha) { - View owner = mOwner.get(); + final View owner = mOwner.get(); if (owner == null) { return; } @@ -424,7 +424,15 @@ public void getOutline(View view, Outline outline) { right = Math.max(left + 1, right - view.getPaddingRight()); bottom = Math.max(top + 1, bottom - view.getPaddingBottom()); } - outline.setAlpha(mShadowAlpha); + + float shadowAlpha = mShadowAlpha; + if (mShadowElevation == 0) { + // outline.setAlpha will work even if shadowElevation == 0 + shadowAlpha = 1f; + } + + outline.setAlpha(shadowAlpha); + if (mRadius <= 0) { outline.setRect(left, top, right, bottom); @@ -434,7 +442,6 @@ public void getOutline(View view, Outline outline) { } } }); - owner.setClipToOutline(mRadius > 0); }