diff --git a/doric-android/doric/src/main/java/pub/doric/DoricContext.java b/doric-android/doric/src/main/java/pub/doric/DoricContext.java index 4592f032..abe6018a 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricContext.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricContext.java @@ -245,16 +245,20 @@ public class DoricContext { public void reload(String script) { retainedJavaValues.clear(); - getDriver().destroyContext(getContextId()); + IDoricDriver driver = getDriver(); + driver.destroyContext(getContextId()).synchronous().get(); for (DoricJavaPlugin javaPlugin : mPluginMap.values()) { javaPlugin.onTearDown(); } mPluginMap.clear(); + if (driver instanceof DoricNativeDriver) { + ((DoricNativeDriver) driver).clearPendingJobs(); + } this.script = script; this.mRootNode.setId(""); this.mRootNode.clearSubModel(); this.mRootNode.getView().removeAllViews(); - getDriver().createContext(mContextId, script, source); + driver.createContext(mContextId, script, source); init(this.extra); callEntity(DoricConstant.DORIC_ENTITY_CREATE); callEntity(DoricConstant.DORIC_ENTITY_BUILD, this.initParams); diff --git a/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java b/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java index 4ea3138f..c6e9e15a 100644 --- a/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java +++ b/doric-android/doric/src/main/java/pub/doric/DoricNativeDriver.java @@ -232,4 +232,8 @@ public class DoricNativeDriver implements IDoricDriver { public DoricJSEngine getDoricJSEngine() { return doricJSEngine; } + + public void clearPendingJobs() { + this.mUIHandler.removeCallbacksAndMessages(null); + } }