feat: update EffectDemo and fix some code problems

This commit is contained in:
pengfei.zhou
2021-11-26 13:48:29 +08:00
committed by osborn
parent 7c9e13158d
commit 91f154cd9b
5 changed files with 266 additions and 22 deletions

View File

@@ -62,6 +62,9 @@ public class AeroEffectView extends DoricLayer {
@Override
protected void dispatchDraw(Canvas canvas) {
if (canvas.getWidth() <= 0 || canvas.getHeight() <= 0) {
return;
}
if (mFullBitmap == null
|| mFullBitmap.getWidth() != canvas.getWidth()
|| mFullBitmap.getHeight() != canvas.getHeight()) {

View File

@@ -46,7 +46,7 @@ public class AeroEffectViewNode extends StackNode {
if ("effectiveRect".equals(name)) {
if (prop.isObject()) {
int x = DoricUtils.dp2px(prop.asObject().getProperty("x").asNumber().toFloat());
int y = DoricUtils.dp2px(prop.asObject().getProperty("x").asNumber().toFloat());
int y = DoricUtils.dp2px(prop.asObject().getProperty("y").asNumber().toFloat());
int width = DoricUtils.dp2px(prop.asObject().getProperty("width").asNumber().toFloat());
int height = DoricUtils.dp2px(prop.asObject().getProperty("height").asNumber().toFloat());
((AeroEffectView) view).setEffectiveRect(new Rect(x, y, x + width, y + height));

View File

@@ -61,6 +61,9 @@ public class BlurEffectView extends DoricLayer {
@Override
protected void dispatchDraw(Canvas canvas) {
if (canvas.getWidth() <= 0 || canvas.getHeight() <= 0) {
return;
}
if (mFullBitmap == null
|| mFullBitmap.getWidth() != canvas.getWidth()
|| mFullBitmap.getHeight() != canvas.getHeight()) {

View File

@@ -50,7 +50,7 @@ public class BlurEffectViewNode extends StackNode {
} else if ("effectiveRect".equals(name)) {
if (prop.isObject()) {
int x = DoricUtils.dp2px(prop.asObject().getProperty("x").asNumber().toFloat());
int y = DoricUtils.dp2px(prop.asObject().getProperty("x").asNumber().toFloat());
int y = DoricUtils.dp2px(prop.asObject().getProperty("y").asNumber().toFloat());
int width = DoricUtils.dp2px(prop.asObject().getProperty("width").asNumber().toFloat());
int height = DoricUtils.dp2px(prop.asObject().getProperty("height").asNumber().toFloat());
((BlurEffectView) view).setEffectiveRect(new Rect(x, y, x + width, y + height));