diff --git a/doric-android/doric/src/main/java/pub/doric/refresh/RefreshableNode.java b/doric-android/doric/src/main/java/pub/doric/refresh/RefreshableNode.java index 3026be81..d7903305 100644 --- a/doric-android/doric/src/main/java/pub/doric/refresh/RefreshableNode.java +++ b/doric-android/doric/src/main/java/pub/doric/refresh/RefreshableNode.java @@ -1,15 +1,20 @@ package pub.doric.refresh; +import com.github.pengfeizhou.jscore.JSDecoder; import com.github.pengfeizhou.jscore.JSObject; import com.github.pengfeizhou.jscore.JSValue; import com.github.pengfeizhou.jscore.JavaValue; +import java.util.concurrent.Callable; + import pub.doric.DoricContext; +import pub.doric.async.AsyncResult; import pub.doric.extension.bridge.DoricMethod; import pub.doric.extension.bridge.DoricPlugin; import pub.doric.extension.bridge.DoricPromise; import pub.doric.shader.SuperNode; import pub.doric.shader.ViewNode; +import pub.doric.utils.DoricJSDispatcher; /** * @Description: pub.doric.pullable @@ -25,6 +30,8 @@ public class RefreshableNode extends SuperNode implements Pull private String mHeaderViewId; private ViewNode mHeaderNode; + private final DoricJSDispatcher jsDispatcher = new DoricJSDispatcher(); + public RefreshableNode(DoricContext doricContext) { super(doricContext); } @@ -184,6 +191,7 @@ public class RefreshableNode extends SuperNode implements Pull @Override public void startAnimation() { + jsDispatcher.clear(); if (mHeaderNode != null) { mHeaderNode.callJSResponse("startAnimation"); } @@ -191,15 +199,21 @@ public class RefreshableNode extends SuperNode implements Pull @Override public void stopAnimation() { + jsDispatcher.clear(); if (mHeaderNode != null) { mHeaderNode.callJSResponse("stopAnimation"); } } @Override - public void setPullingDistance(float rotation) { + public void setPullingDistance(final float rotation) { if (mHeaderNode != null) { - mHeaderNode.callJSResponse("setPullingDistance", rotation); + jsDispatcher.dispatch(new Callable>() { + @Override + public AsyncResult call() throws Exception { + return mHeaderNode.callJSResponse("setPullingDistance", rotation); + } + }); } } } diff --git a/doric-android/doric/src/main/java/pub/doric/utils/DoricJSDispatcher.java b/doric-android/doric/src/main/java/pub/doric/utils/DoricJSDispatcher.java index c4668f6e..343f108a 100644 --- a/doric-android/doric/src/main/java/pub/doric/utils/DoricJSDispatcher.java +++ b/doric-android/doric/src/main/java/pub/doric/utils/DoricJSDispatcher.java @@ -84,4 +84,8 @@ public class DoricJSDispatcher implements AsyncResult.Callback { }); } } + + public void clear() { + blocks.clear(); + } }