Skip to content

Commit

Permalink
bugfix:修复椭圆、圆形在按了电源键息屏后回来重复绘制,让高斯模糊再次模糊一次问题
Browse files Browse the repository at this point in the history
  • Loading branch information
centerzx committed Oct 15, 2022
1 parent 09d6634 commit df8aff9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

2、在需要使用的gradle文件添加依赖:
```
implementation 'com.github.centerzx:ShapeBlurView:1.0.4'
implementation 'com.github.centerzx:ShapeBlurView:1.0.5'
implementation 'androidx.appcompat:appcompat:***'
```

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
app:blur_border_color="@color/purple_500"
app:blur_border_width="1dp"
app:blur_mode="oval"
app:blur_overlay_color="#80008000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/blurview1" />
Expand Down
6 changes: 3 additions & 3 deletions blurview/src/main/java/net/center/blurview/ShapeBlurView.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class ShapeBlurView extends View {
private final Paint mBorderPaint;
private float mBorderWidth = 0;
private ColorStateList mBorderColor = ColorStateList.valueOf(DEFAULT_BORDER_COLOR);
private Matrix matrix;
private Matrix matrix = new Matrix();
private BitmapShader shader;

public ShapeBlurView(Context context, AttributeSet attrs) {
Expand Down Expand Up @@ -644,8 +644,8 @@ private void drawOvalRectBitmap(Canvas canvas, Bitmap blurBitmap, int overlayCol
}
if (matrix == null) {
matrix = new Matrix();
matrix.postScale(mRectFDst.width() / blurBitmap.getWidth(), mRectFDst.height() / blurBitmap.getHeight());
}
matrix.postScale(mRectFDst.width() / blurBitmap.getWidth(), mRectFDst.height() / blurBitmap.getHeight());
shader.setLocalMatrix(matrix);
mBitmapPaint.setShader(shader);
canvas.drawOval(mRectFDst, mBitmapPaint);
Expand Down Expand Up @@ -683,8 +683,8 @@ private void drawCircleRectBitmap(Canvas canvas, Bitmap blurBitmap, int overlayC
}
if (matrix == null) {
matrix = new Matrix();
matrix.postScale(mRectFDst.width() / mRectSrc.width(), mRectFDst.height() / mRectSrc.height());
}
matrix.postScale(mRectFDst.width() / mRectSrc.width(), mRectFDst.height() / mRectSrc.height());
shader.setLocalMatrix(matrix);
mBitmapPaint.setShader(shader);
//前面Scale,故判断以哪一个来取中心点和半径
Expand Down

0 comments on commit df8aff9

Please sign in to comment.