com.taobao.weex.adapter.IWXUserTrackAdapter Java Examples

The following examples show how to use com.taobao.weex.adapter.IWXUserTrackAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WXDomStatement.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * Create a command object for scroll the given view to the specified position.
 * @param ref Reference of the dom.
 * @param options the specified position
 */
void scrollToDom(final String ref, final JSONObject options) {
  if (mDestroy) {
    return;
  }
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);

  mNormalTasks.add(new IWXRenderTask() {

    @Override
    public void execute() {
      mWXRenderManager.scrollToComponent(mInstanceId, ref, options);
    }

    @Override
    public String toString() {
      return "scrollToPosition";
    }
  });

  mDirty = true;
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #2
Source File: WXSoInstallMgrSdk.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * Load .so library
 */
static boolean _loadUnzipSo(String libName, int version, IWXUserTrackAdapter utAdapter) {
  boolean initSuc = false;
  try {
    if (isExist(libName, version)) {
      System.load(_targetSoFile(libName, version));
      commit(utAdapter, "2000", "Load file extract from apk successfully.");
    }
    initSuc = true;
  } catch (Exception e) {
    commit(utAdapter, WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorCode(), WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorMsg() + ":" + e.getMessage());
    initSuc = false;
    e.printStackTrace();
  } catch (java.lang.UnsatisfiedLinkError e2) {
    commit(utAdapter, WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorCode(), WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorMsg() + ":" + e2.getMessage());
    initSuc = false;
    e2.printStackTrace();

  } catch (java.lang.Error e3) {
    commit(utAdapter, WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorCode(), WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorMsg() + ":" + e3.getMessage());
    initSuc = false;
    e3.printStackTrace();
  }
  return initSuc;
}
 
Example #3
Source File: RemoveEventAction.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void executeDom(DOMActionContext context) {
  if (context.isDestory()) {
    return;
  }
  WXSDKInstance instance = context.getInstance();
  WXDomObject domObject = context.getDomByRef(mRef);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEEVENT);
    }
    return;
  }
  domObject.removeEvent(mEvent);
  mUpdatedDomObject = domObject;
  context.postRenderTask(this);
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #4
Source File: WXSoInstallMgrSdk.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * Load .so library
 */
static boolean _loadUnzipSo(String libName, int version, IWXUserTrackAdapter utAdapter) {
  boolean initSuc = false;
  try {
    if (isExist(libName, version)) {
      System.load(_targetSoFile(libName, version));
      commit(utAdapter, "2000", "Load file extract from apk successfully.");
    }
    initSuc = true;
  } catch (Throwable e) {
    commit(utAdapter, WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorCode(), WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorMsg() + ":" + e.getMessage());
    initSuc = false;
    WXLogUtils.e("", e);
  }
  return initSuc;
}
 
Example #5
Source File: UpdateAttributeAction.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void executeDom(DOMActionContext context) {
  if (context.isDestory()) {
    return;
  }
  WXSDKInstance instance = context.getInstance();
  final WXDomObject domObject = context.getDomByRef(mRef);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATEATTRS);
    }
    return;
  }

  domObject.updateAttr(mData);
  context.postRenderTask(this);

  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #6
Source File: AddEventAction.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void executeDom(DOMActionContext context) {
  if (context.isDestory()) {
    return;
  }
  WXSDKInstance instance = context.getInstance();
  WXDomObject domObject = context.getDomByRef(mRef);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_ADDEVENT);
    }
    return;
  }
  domObject.addEvent(mEvent);
  mUpdatedDom = domObject;
  context.postRenderTask(this);

  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #7
Source File: WXDomStatement.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * Create a command object for notifying {@link WXRenderManager} that the process of update
 * given view is finished, and put the command object in the queue.
 */
void updateFinish() {
  if (mDestroy) {
    return;
  }
  mNormalTasks.add(new IWXRenderTask() {

    @Override
    public void execute() {
      mWXRenderManager.updateFinish(mInstanceId);
    }

    @Override
    public String toString() {
      return "updateFinish";
    }
  });

  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #8
Source File: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg) {
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId);
  if (instance == null || errCode == null) {
    return;
  }
  // TODO: We should move WXPerformance and IWXUserTrackAdapter
  // into a adapter level.
  // comment out the line below to prevent commiting twice.
  //instance.commitUTStab(WXConst.JS_BRIDGE, errCode, errMsg);

  IWXUserTrackAdapter adapter = WXSDKManager.getInstance().getIWXUserTrackAdapter();
  if (adapter == null) {
    return;
  }
  WXPerformance performance = new WXPerformance();
  performance.args=instance.getBundleUrl();
  performance.errCode=errCode.getErrorCode();
  if (errCode != WXErrorCode.WX_SUCCESS) {
    performance.appendErrMsg(TextUtils.isEmpty(errMsg)?errCode.getErrorMsg():errMsg);
    WXLogUtils.e("wx_monitor",performance.toString());
  }
  adapter.commit(WXEnvironment.getApplication(), null, IWXUserTrackAdapter.JS_BRIDGE, performance, instance.getUserTrackParams());
}
 
Example #9
Source File: WXSoInstallMgrSdk.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
static void commit(IWXUserTrackAdapter utAdapter, String errCode, String errMsg) {
  if (mStatisticsListener != null) {
    mStatisticsListener.onException("0", errCode, errMsg);
  }

  if (utAdapter == null) {
    return;
  }
  if (errCode != null && errMsg != null) {
    WXPerformance p = new WXPerformance();
    p.errCode = errCode;
    p.errMsg = errMsg;
    utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, p, null);
  } else {
    utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, null, null);

  }
}
 
Example #10
Source File: WXSoInstallMgrSdk.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * Load .so library
 */
static boolean _loadUnzipSo(String libName,
                            int version,
                            IWXUserTrackAdapter utAdapter) {
  boolean initSuc = false;
  try {
    if (isExist(libName, version)) {
      // If a library loader adapter exists, use this adapter to load library
      // instead of System.load.
      if (mSoLoader != null) {
        mSoLoader.doLoad(_targetSoFile(libName, version));
      } else {
        System.load(_targetSoFile(libName, version));
      }
      commit(utAdapter, "2000", "Load file extract from apk successfully.");
    }
    initSuc = true;
  } catch (Throwable e) {
    commit(utAdapter,
           WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorCode(),
           WXErrorCode.WX_ERR_COPY_FROM_APK.getErrorMsg() + ":" + e.getMessage());
    initSuc = false;
    WXLogUtils.e("", e);
  }
  return initSuc;
}
 
Example #11
Source File: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg) {
  if (TextUtils.isEmpty(type) || errorCode == null) {
    return;
  }
  if (WXSDKManager.getInstance().getWXStatisticsListener() != null) {
    WXSDKManager.getInstance().getWXStatisticsListener().onException("0",
        errorCode.getErrorCode(),
        TextUtils.isEmpty(errMsg) ? errorCode.getErrorMsg() : errMsg);
  }

  final IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter();
  if (userTrackAdapter == null) {
    return;
  }
  WXPerformance performance = new WXPerformance();
  performance.errCode = errorCode.getErrorCode();
  if (errorCode != WXErrorCode.WX_SUCCESS) {
    performance.appendErrMsg(TextUtils.isEmpty(errMsg)?errorCode.getErrorMsg():errMsg);
    WXLogUtils.e("wx_monitor",performance.toString());
  }
  userTrackAdapter.commit(WXEnvironment.getApplication(), null, type, performance, null);
}
 
Example #12
Source File: WXSDKEngine.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
/**
 * Deprecated. Use {@link #initialize(Application, InitConfig)} instead.
 */
@Deprecated
public static void init(Application application, IWXUserTrackAdapter utAdapter, String framework) {
  initialize(application,
    new InitConfig.Builder()
      .setUtAdapter(utAdapter)
      .build()
  );
}
 
Example #13
Source File: UpdateFinishAction.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void executeDom(DOMActionContext context) {
  if (context.isDestory()) {
    return;
  }
  context.postRenderTask(this);

  WXSDKInstance instance = context.getInstance();
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #14
Source File: AddElementAction.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
protected void appendDomToTree(DOMActionContext context, WXDomObject domObject) {
  WXDomObject parent;
  mRef = domObject.getRef();
  if ((parent = context.getDomByRef(mParentRef)) == null) {
    context.getInstance().commitUTStab(IWXUserTrackAdapter.DOM_MODULE, getErrorCode());
    return;
  } else {
    //non-root and parent exist
    parent.add(domObject, mAddIndex);
  }
}
 
Example #15
Source File: RemoveElementAction.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void executeDom(DOMActionContext context) {
  if (context.isDestory()) {
    return;
  }
  WXSDKInstance instance = context.getInstance();
  WXDomObject domObject = context.getDomByRef(mRef);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT);
    }
    return;
  }
  WXDomObject parent = domObject.parent;
  if (parent == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT);
    }
    return;
  }
  domObject.traverseTree(context.getRemoveElementConsumer());
  parent.remove(domObject);
  context.unregisterDOMObject(mRef);

  context.postRenderTask(this);

  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #16
Source File: MoveElementAction.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void executeDom(DOMActionContext context) {
  if (context.isDestory()) {
    return;
  }
  WXSDKInstance instance = context.getInstance();
  WXDomObject domObject = context.getDomByRef(mRef);
  WXDomObject parentObject = context.getDomByRef(mParentRef);
  if (domObject == null || domObject.parent == null
      || parentObject == null || parentObject.hasNewLayout()) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_MOVEELEMENT);
    }
    return;
  }
  int index = mIndex;
  if (domObject.parent.equals(parentObject)) {
    if(parentObject.index(domObject) == index) {
      return;
    } else if(domObject.parent.index(domObject)< index){
      index = index -1;
    }
  }

  mNewIndex = index;
  domObject.parent.remove(domObject);
  parentObject.add(domObject, mNewIndex);

  context.postRenderTask(this);
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #17
Source File: UpdateStyleAction.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void executeDom(DOMActionContext context) {
  if (context.isDestory() || mData == null) {
    return;
  }
  WXSDKInstance instance = context.getInstance();
  WXDomObject domObject = context.getDomByRef(mRef);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATESTYLE);
    }
    return;
  }
  mPadding = domObject.getPadding();
  mBorder = domObject.getBorder();

  Map<String, Object> animationMap = new ArrayMap<>(2);
  animationMap.put(WXDomObject.TRANSFORM, mData.get(WXDomObject.TRANSFORM));
  animationMap.put(WXDomObject.TRANSFORM_ORIGIN, mData.get(WXDomObject.TRANSFORM_ORIGIN));

  context.addAnimationForElement(mRef, animationMap);

  if (!mData.isEmpty()) {
    domObject.updateStyle(mData, mIsCausedByPesudo);
    domObject.traverseTree(context.getApplyStyleConsumer());
    context.postRenderTask(this);
  }

  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #18
Source File: WXBridgeManager.java    From weex-uikit with MIT License 5 votes vote down vote up
public void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg) {
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId);
  IWXUserTrackAdapter adapter = WXSDKManager.getInstance().getIWXUserTrackAdapter();
  if (instance == null || adapter == null || errCode == null) {
    return;
  }
  WXPerformance performance = new WXPerformance();
  performance.args=instance.getBundleUrl();
  performance.errCode=errCode.getErrorCode();
  if (errCode != WXErrorCode.WX_SUCCESS) {
    performance.appendErrMsg(TextUtils.isEmpty(errMsg)?errCode.getErrorMsg():errMsg);
    WXLogUtils.e("wx_monitor",performance.toString());
  }
  adapter.commit(WXEnvironment.getApplication(), null, IWXUserTrackAdapter.JS_BRIDGE, performance, instance.getUserTrackParams());
}
 
Example #19
Source File: WXBridgeManager.java    From weex-uikit with MIT License 5 votes vote down vote up
public void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg) {
  final IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter();
  if (userTrackAdapter == null || TextUtils.isEmpty(type) || errorCode == null) {
    return;
  }
  WXPerformance performance = new WXPerformance();
  performance.errCode = errorCode.getErrorCode();
  if (errorCode != WXErrorCode.WX_SUCCESS) {
    performance.appendErrMsg(TextUtils.isEmpty(errMsg)?errorCode.getErrorMsg():errMsg);
    WXLogUtils.e("wx_monitor",performance.toString());
  }
  userTrackAdapter.commit(WXEnvironment.getApplication(), null, type, performance, null);
}
 
Example #20
Source File: WXSoInstallMgrSdk.java    From weex-uikit with MIT License 5 votes vote down vote up
static void commit(IWXUserTrackAdapter utAdapter, String errCode, String errMsg) {
  if (utAdapter == null) {
    return;
  }
  if (errCode != null && errMsg != null) {
    WXPerformance p = new WXPerformance();
    p.errCode = errCode;
    p.errMsg = errMsg;
    utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, p, null);
  } else {
    utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, null, null);

  }
}
 
Example #21
Source File: WXSoInstallMgrSdk.java    From weex with Apache License 2.0 5 votes vote down vote up
static void commit(IWXUserTrackAdapter utAdapter, String errCode, String errMsg) {
  if (utAdapter == null) {
    return;
  }
  if (errCode != null && errMsg != null) {
    WXPerformance p = new WXPerformance();
    p.errCode = errCode;
    p.errMsg = errMsg;
    utAdapter.commit(null, null, WXConst.ENVIRONMENT, p, null);
  } else {
    utAdapter.commit(null, null, WXConst.ENVIRONMENT, null, null);

  }
}
 
Example #22
Source File: WXSDKEngine.java    From weex-uikit with MIT License 5 votes vote down vote up
@Deprecated
public static void init(Application application, String framework, IWXUserTrackAdapter utAdapter, IWXImgLoaderAdapter imgLoaderAdapter, IWXHttpAdapter httpAdapter) {
  initialize(application,
    new InitConfig.Builder()
      .setUtAdapter(utAdapter)
      .setHttpAdapter(httpAdapter)
      .setImgAdapter(imgLoaderAdapter)
      .build()
  );
}
 
Example #23
Source File: WXSDKEngine.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Deprecated. Use {@link #initialize(Application, InitConfig)} instead.
 */
@Deprecated
public static void init(Application application, IWXUserTrackAdapter utAdapter, String framework) {
  initialize(application,
    new InitConfig.Builder()
      .setUtAdapter(utAdapter)
      .build()
  );
}
 
Example #24
Source File: WXDomStatement.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Update the attributes according to the given attribute. Then creating a
 * command object for updating corresponding view and put the command object in the queue.
 * @param ref Reference of the dom.
 * @param attrs the new style. This style is only a part of the full attribute set, and will be
 *              merged into attributes
 * @see #updateStyle(String, JSONObject)
 */
void updateAttrs(String ref, final JSONObject attrs) {
  if (mDestroy) {
    return;
  }
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  final WXDomObject domObject = mRegistry.get(ref);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATEATTRS);
    }
    return;
  }

  domObject.updateAttr(attrs);

  mNormalTasks.add(new IWXRenderTask() {

    @Override
    public void execute() {
      mWXRenderManager.updateAttrs(mInstanceId, domObject.getRef(), attrs);
    }

    @Override
    public String toString() {
      return "updateAttr";
    }
  });
  mDirty = true;

  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #25
Source File: WXDomStatement.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Update styles according to the given style. Then creating a
 * command object for updating corresponding view and put the command object in the queue.
 * @param ref Reference of the dom.
 * @param style the new style. This style is only a part of the full style, and will be merged
 *              into styles
 * @param byPesudo updateStyle by pesduo class
 * @see #updateAttrs(String, JSONObject)
 */
void updateStyle(String ref, JSONObject style, boolean byPesudo) {
  if (mDestroy || style == null) {
    return;
  }
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  WXDomObject domObject = mRegistry.get(ref);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATESTYLE);
    }
    return;
  }

  Map<String, Object> animationMap= new ArrayMap<>(2);
  animationMap.put(WXDomObject.TRANSFORM, style.remove(WXDomObject.TRANSFORM));
  animationMap.put(WXDomObject.TRANSFORM_ORIGIN, style.remove(WXDomObject.TRANSFORM_ORIGIN));
  animations.add(new Pair<>(ref, animationMap));

  if(!style.isEmpty()){
    domObject.updateStyle(style, byPesudo);
    domObject.traverseTree(ApplyStyleConsumer.getInstance());
    updateStyle(domObject, style);
  }
  mDirty = true;

  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #26
Source File: WXDomStatement.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Create a command object for adding a default event listener to the corresponding {@link
 * WXDomObject} and put the command object in the queue.
 * When the event is triggered, the eventListener will call {@link WXSDKManager#fireEvent(String, String, String)}
 * , and the JS will handle all the operations from there.
 *
 * @param ref Reference of the dom.
 * @param type the type of the event, this may be a plain event defined in
 * {@link com.taobao.weex.common.Constants.Event} or a gesture defined in {@link com.taobao
 * .weex.ui.view.gesture.WXGestureType}
 */
void addEvent(final String ref, final String type) {
  if (mDestroy) {
    return;
  }
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  final WXDomObject domObject = mRegistry.get(ref);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_ADDEVENT);
    }
    return;
  }
  domObject.addEvent(type);
  mNormalTasks.add(new IWXRenderTask() {

    @Override
    public void execute() {
      WXComponent comp = mWXRenderManager.getWXComponent(mInstanceId,ref);
      if(comp != null){
        //sync dom change to component
        comp.updateDom(domObject);
        mWXRenderManager.addEvent(mInstanceId, ref, type);
      }
    }

    @Override
    public String toString() {
      return "Add event";
    }
  });

  mDirty = true;
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #27
Source File: WXDomStatement.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Create a command object for removing the event listener of the corresponding {@link
 * WXDomObject} and put the command event in the queue.
 * @param ref Reference of the dom.
 * @param type the type of the event, this may be a plain event defined in
 * {@link com.taobao.weex.common.Constants.Event} or a gesture defined in {@link com.taobao
 * .weex.ui.view.gesture.WXGestureType}
 */
void removeEvent(final String ref, final String type) {
  if (mDestroy) {
    return;
  }
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  final WXDomObject domObject = mRegistry.get(ref);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEEVENT);
    }
    return;
  }
  domObject.removeEvent(type);

  mNormalTasks.add(new IWXRenderTask() {

    @Override
    public void execute() {
      WXComponent comp = mWXRenderManager.getWXComponent(mInstanceId,ref);
      if(comp != null){
        //sync dom change to component
        comp.updateDom(domObject);
        mWXRenderManager.removeEvent(mInstanceId, ref, type);
      }

    }

    @Override
    public String toString() {
      return "removeEvent";
    }
  });

  mDirty = true;
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #28
Source File: WXDomStatement.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Create a command object for notifying {@link WXRenderManager} that the process of creating
 * given view is finished, and put the command object in the queue.
 */
void createFinish() {
  if (mDestroy) {
    return;
  }

  final WXDomObject root = mRegistry.get(WXDomObject.ROOT);
  mNormalTasks.add(new IWXRenderTask() {

    @Override
    public void execute() {
      mWXRenderManager.createFinish(mInstanceId,
                                    (int) root.getLayoutWidth(),
                                    (int) root.getLayoutHeight());
    }

    @Override
    public String toString() {
      return "createFinish";
    }
  });

  mDirty = true;
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #29
Source File: WXDomStatement.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Create a command object for notifying {@link WXRenderManager} that the process of refreshing
 * given view is finished, and put the command object in the queue.
 */
void refreshFinish() {
  if (mDestroy) {
    return;
  }
  final WXDomObject root = mRegistry.get(WXDomObject.ROOT);
  mNormalTasks.add(new IWXRenderTask() {

    @Override
    public void execute() {
      int realWidth = (int) root.getLayoutWidth();
      int realHeight = (int) root.getLayoutHeight();
      mWXRenderManager.refreshFinish(mInstanceId, realWidth, realHeight);
    }

    @Override
    public String toString() {
      return "refreshFinish";
    }
  });

  mDirty = true;
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
Example #30
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public void onActivityPause() {
  onViewDisappear();
  if(!isCommit){
    Set<String> componentTypes= WXComponentFactory.getComponentTypesByInstanceId(getInstanceId());
    if(componentTypes!=null && componentTypes.contains(WXBasicComponentType.SCROLLER)){
      mWXPerformance.useScroller=1;
    }
    mWXPerformance.maxDeepViewLayer=getMaxDeepLayer();
    if (mUserTrackAdapter != null) {
      mUserTrackAdapter.commit(mContext, null, IWXUserTrackAdapter.LOAD, mWXPerformance, getUserTrackParams());
    }
    isCommit=true;
  }
  // module listen Activity onActivityPause
  WXModuleManager.onActivityPause(getInstanceId());
  if(mRootComp != null) {
    mRootComp.onActivityPause();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely,onActivityPause can not be call!");
  }

  Intent intent=new Intent(WXGlobalEventReceiver.EVENT_ACTION);
  intent.putExtra(WXGlobalEventReceiver.EVENT_NAME,Constants.Event.PAUSE_EVENT);
  intent.putExtra(WXGlobalEventReceiver.EVENT_WX_INSTANCEID,getInstanceId());
  mContext.sendBroadcast(intent);
}