android:fix type cast error

This commit is contained in:
pengfei.zhou 2020-09-11 10:34:03 +08:00 committed by osborn
parent fc6b465b92
commit ed5c2103b0
2 changed files with 30 additions and 26 deletions

View File

@ -354,6 +354,9 @@ public class ImageNode extends ViewNode<ImageView> {
loadImageUrl(prop.asString().value()); loadImageUrl(prop.asString().value());
break; break;
case "scaleType": case "scaleType":
if (!prop.isNumber()) {
return;
}
int scaleType = prop.asNumber().toInt(); int scaleType = prop.asNumber().toInt();
switch (scaleType) { switch (scaleType) {
case 1: case 1:

View File

@ -267,32 +267,33 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
} }
JSValue orientation = dict.asObject().getProperty("orientation"); JSValue orientation = dict.asObject().getProperty("orientation");
if (orientation.isNumber()) {
switch (orientation.asNumber().toInt()) { switch (orientation.asNumber().toInt()) {
case 0: case 0:
linearGradient = new LinearGradient(0.f, 0.f, 0.f, height, colors, locations, Shader.TileMode.CLAMP); linearGradient = new LinearGradient(0.f, 0.f, 0.f, height, colors, locations, Shader.TileMode.CLAMP);
break; break;
case 1: case 1:
linearGradient = new LinearGradient(width, 0.f, 0.f, height, colors, locations, Shader.TileMode.CLAMP); linearGradient = new LinearGradient(width, 0.f, 0.f, height, colors, locations, Shader.TileMode.CLAMP);
break; break;
case 2: case 2:
linearGradient = new LinearGradient(width, 0.f, 0.f, 0.f, colors, locations, Shader.TileMode.CLAMP); linearGradient = new LinearGradient(width, 0.f, 0.f, 0.f, colors, locations, Shader.TileMode.CLAMP);
break; break;
case 3: case 3:
linearGradient = new LinearGradient(width, height, 0.f, 0.f, colors, locations, Shader.TileMode.CLAMP); linearGradient = new LinearGradient(width, height, 0.f, 0.f, colors, locations, Shader.TileMode.CLAMP);
break; break;
case 4: case 4:
linearGradient = new LinearGradient(0.f, height, 0.f, 0.f, colors, locations, Shader.TileMode.CLAMP); linearGradient = new LinearGradient(0.f, height, 0.f, 0.f, colors, locations, Shader.TileMode.CLAMP);
break; break;
case 5: case 5:
linearGradient = new LinearGradient(0.f, height, width, 0.f, colors, locations, Shader.TileMode.CLAMP); linearGradient = new LinearGradient(0.f, height, width, 0.f, colors, locations, Shader.TileMode.CLAMP);
break; break;
case 6: case 6:
linearGradient = new LinearGradient(0.f, 0.f, width, 0.f, colors, locations, Shader.TileMode.CLAMP); linearGradient = new LinearGradient(0.f, 0.f, width, 0.f, colors, locations, Shader.TileMode.CLAMP);
break; break;
case 7: case 7:
linearGradient = new LinearGradient(0.f, 0.f, width, height, colors, locations, Shader.TileMode.CLAMP); linearGradient = new LinearGradient(0.f, 0.f, width, height, colors, locations, Shader.TileMode.CLAMP);
break; break;
}
} }
return linearGradient; return linearGradient;