Skip to content

Commit 8c2c189

Browse files
committed
[Fix] Work around crash due to MD2 popup path not considered convex.
1 parent 7b96256 commit 8c2c189

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

library/src/main/java/me/zhanghai/android/fastscroll/Md2PopupBackground.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.graphics.PixelFormat;
2828
import android.graphics.Rect;
2929
import android.graphics.drawable.Drawable;
30+
import android.os.Build;
3031
import android.view.View;
3132

3233
import androidx.annotation.NonNull;
@@ -139,6 +140,13 @@ public boolean getPadding(@NonNull Rect padding) {
139140

140141
@Override
141142
public void getOutline(@NonNull Outline outline) {
143+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q && !mPath.isConvex()) {
144+
// The outline path must be convex before Q, but we may run into floating point error
145+
// caused by calculation involving sqrt(2) or OEM implementation difference, so in this
146+
// case we just omit the shadow instead of crashing.
147+
super.getOutline(outline);
148+
return;
149+
}
142150
outline.setConvexPath(mPath);
143151
}
144152
}

0 commit comments

Comments
 (0)