Skip to content

Commit

Permalink
bugfix: Swipe back will flash at the end. #443
Browse files Browse the repository at this point in the history
  • Loading branch information
cgspine committed Nov 22, 2018
1 parent a9ea035 commit d6296fa
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions qmui/src/main/java/com/qmuiteam/qmui/layout/QMUILayoutHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -434,7 +442,6 @@ public void getOutline(View view, Outline outline) {
}
}
});

owner.setClipToOutline(mRadius > 0);

}
Expand Down

0 comments on commit d6296fa

Please sign in to comment.