From c2264e621c723502da95b2b02847ef669392baf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Sat, 9 May 2020 11:39:58 +0800 Subject: [PATCH] Android: ensure start & end are not null --- .../doric/src/main/java/pub/doric/shader/ViewNode.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doric-android/doric/src/main/java/pub/doric/shader/ViewNode.java b/doric-android/doric/src/main/java/pub/doric/shader/ViewNode.java index a28ad2e2..c04e4d4d 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/ViewNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/ViewNode.java @@ -243,10 +243,12 @@ public abstract class ViewNode extends DoricContextHolder { gradientDrawable.setColors(colors.asArray().toIntArray()); } else { - JSValue start = prop.asObject().getProperty("start"); - JSValue end = prop.asObject().getProperty("end"); + if (prop.asObject().propertySet().contains("start") && prop.asObject().propertySet().contains("end")) { + JSValue start = prop.asObject().getProperty("start"); + JSValue end = prop.asObject().getProperty("end"); - gradientDrawable.setColors(new int[]{start.asNumber().toInt(), end.asNumber().toInt()}); + gradientDrawable.setColors(new int[]{start.asNumber().toInt(), end.asNumber().toInt()}); + } } JSValue orientation = prop.asObject().getProperty("orientation");