Skip to content

Commit

Permalink
Merge "Fix crash java.lang.IllegalArgumentException" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
SongFerng Wang authored and Android (Google) Code Review committed Jun 4, 2024
2 parents 3ab283c + 025e56e commit 57f25a8
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;

Expand All @@ -33,6 +34,7 @@ public class QrDecorateView extends View {
private static final float CORNER_STROKE_WIDTH = 4f; // 4dp
private static final float CORNER_LINE_LENGTH = 264f; // 264dp
private static final float CORNER_RADIUS = 16f; // 16dp
private static final String TAG = "QrDecorateView";

private final int mCornerColor;
private final int mFocusedCornerColor;
Expand Down Expand Up @@ -94,6 +96,10 @@ public QrDecorateView(Context context, AttributeSet attrs, int defStyleAttr, int
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (getWidth() <= 0 || getHeight() <= 0) {
Log.e(TAG, "width and height must be > 0");
return;
}

if (mMaskBitmap == null) {
mMaskBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
Expand Down

0 comments on commit 57f25a8

Please sign in to comment.