コード例 #1
0
ファイル: WXDomStatement.java プロジェクト: Rowandjj/weex
  /**
   * 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
   * @see #updateAttrs(String, JSONObject)
   */
  void updateStyle(String ref, JSONObject style) {
    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 = WXDataStructureUtil.newHashMapWithExpectedSize(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);
      transformStyle(domObject, false);
      updateStyle(domObject, style);
    }
    mDirty = true;

    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
    }
  }