Exemple #1
0
  /**
   * Walk through the dom tree and create command object of re-calculating {@link
   * android.view.ViewGroup.LayoutParams} for dom that is old.
   *
   * @param dom the root dom of the walk through.
   */
  private void applyUpdate(WXDomObject dom) {
    if (dom == null) {
      return;
    }
    if (dom.hasUpdate()) {
      dom.markUpdateSeen();
      if (!dom.isYoung()) {
        final WXDomObject copy = dom.clone();
        if (copy == null) {
          return;
        }
        mNormalTasks.add(
            new IWXRenderTask() {

              @Override
              public void execute() {
                mWXRenderManager.setLayout(mInstanceId, copy.getRef(), copy);
              }

              @Override
              public String toString() {
                return "setLayout";
              }
            });
        if (dom.getExtra() != null) {
          mNormalTasks.add(
              new IWXRenderTask() {

                @Override
                public void execute() {
                  mWXRenderManager.setExtra(mInstanceId, copy.getRef(), copy.getExtra());
                }

                @Override
                public String toString() {
                  return "setExtra";
                }
              });
        }
      }
    }
    int count = dom.childCount();
    for (int i = 0; i < count; ++i) {
      applyUpdate(dom.getChild(i));
    }
  }
Exemple #2
0
 /**
  * Update the specified component's dom and mark it as old.
  *
  * @param component the component to be updated
  */
 private void updateDomObj(WXComponent component) {
   if (component == null) {
     return;
   }
   WXDomObject domObject = mRegistry.get(component.getRef());
   if (domObject == null) {
     return;
   }
   domObject.old();
   component.updateDom(domObject.clone());
   if (component instanceof WXVContainer) {
     WXVContainer container = (WXVContainer) component;
     int count = container.childCount();
     for (int i = 0; i < count; ++i) {
       updateDomObj(container.getChild(i));
     }
   }
 }