com.taobao.weex.ui.component.WXScroller Java Examples

The following examples show how to use com.taobao.weex.ui.component.WXScroller. 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: WXRenderStatement.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * create RootView ,every weex Instance View has a rootView;
 * @see com.taobao.weex.dom.WXDomStatement#createBody(JSONObject)
 */
void createBody(WXComponent component) {
  long start = System.currentTimeMillis();
  component.createView();
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
  }
  start = System.currentTimeMillis();
  component.applyLayoutAndEvent(component);
  component.bindData(component);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
  }

  if (component instanceof WXScroller) {
    WXScroller scroller = (WXScroller) component;
    if (scroller.getInnerView() instanceof ScrollView) {
      mWXSDKInstance.setRootScrollView((ScrollView) scroller.getInnerView());
    }
  }
  mWXSDKInstance.onRootCreated(component);
  if (mWXSDKInstance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onCreateFinish();
  }
}
 
Example #2
Source File: WXRenderStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * create RootView ,every weex Instance View has a rootView;
 * @see com.taobao.weex.dom.WXDomStatement#createBody(JSONObject)
 */
void createBody(WXComponent component) {
  long start = System.currentTimeMillis();
  component.createView(mGodComponent, -1);
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
  }
  start = System.currentTimeMillis();
  component.applyLayoutAndEvent(component);
  component.bindData(component);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
  }

  if (component instanceof WXScroller) {
    WXScroller scroller = (WXScroller) component;
    if (scroller.getView() instanceof ScrollView) {
      mWXSDKInstance.setRootScrollView((ScrollView) scroller.getView());
    }
  }
  mWXSDKInstance.setRootView(mGodComponent.getRealView());
  if (mWXSDKInstance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onViewCreated(mGodComponent);
  }
}
 
Example #3
Source File: WXSDKEngine.java    From weex with Apache License 2.0 6 votes vote down vote up
private static void register() {
  try {
    registerComponent(WXBasicComponentType.TEXT, WXText.class, false);
    registerComponent(WXBasicComponentType.IMG, WXImage.class, false);
    registerComponent(WXBasicComponentType.DIV, WXDiv.class, false);
    registerComponent(WXBasicComponentType.IMAGE, WXImage.class, false);
    registerComponent(WXBasicComponentType.CONTAINER, WXDiv.class, false);
    registerComponent(WXBasicComponentType.SCROLLER, WXScroller.class, false);
    registerComponent(WXBasicComponentType.SLIDER, WXSlider.class, true);

    registerComponent(WXListComponent.class, false,WXBasicComponentType.LIST,WXBasicComponentType.VLIST);
    registerComponent(HorizontalListComponent.class,false,WXBasicComponentType.HLIST);
    registerComponent(WXBasicComponentType.CELL, WXCell.class, true);
    registerComponent(WXBasicComponentType.INDICATOR, WXIndicator.class, true);
    registerComponent(WXBasicComponentType.VIDEO, WXVideo.class, false);
    registerComponent(WXBasicComponentType.INPUT, WXInput.class, false);
    registerComponent(WXBasicComponentType.SWITCH, WXSwitch.class, false);
    registerComponent(WXBasicComponentType.A, WXA.class, false);
    registerComponent(WXBasicComponentType.EMBED, WXEmbed.class, true);
    registerComponent(WXBasicComponentType.WEB, WXWeb.class);
    registerComponent(WXBasicComponentType.REFRESH, WXRefresh.class);
    registerComponent(WXBasicComponentType.LOADING, WXLoading.class);
    registerComponent(WXBasicComponentType.LOADING_INDICATOR, WXLoadingIndicator.class);

    registerModule("dom", WXDomModule.class, true);
    registerModule("modal", WXModalUIModule.class, false);
    registerModule("instanceWrap", WXInstanceWrap.class, true);
    registerModule("animation", WXAnimationModule.class, true);
    registerModule("webview", WXWebViewModule.class, true);
    registerModule("navigator", WXNavigatorModule.class);
    registerModule("stream", WXStreamModule.class);

    registerDomObject(WXBasicComponentType.TEXT, WXTextDomObject.class);
    registerDomObject(WXBasicComponentType.INPUT, WXTextDomObject.class);
    registerDomObject(WXBasicComponentType.SWITCH, WXSwitchDomObject.class);
  } catch (WXException e) {
    WXLogUtils.e("[WXSDKEngine] register:" + WXLogUtils.getStackTrace(e));
  }
}
 
Example #4
Source File: ComponentHeightComputer.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
static int computeComponentContentHeight(@NonNull WXComponent component) {
    View view = component.getHostView();
    if(view == null) {
        return 0;
    }
    if(component instanceof WXListComponent) {
        WXListComponent listComponent = (WXListComponent) component;
        BounceRecyclerView bounceRecyclerView = listComponent.getHostView();
        if(bounceRecyclerView == null) {
            return 0;
        }
        WXRecyclerView innerView = bounceRecyclerView.getInnerView();
        if(innerView == null) {
            return bounceRecyclerView.getMeasuredHeight();
        } else {
            return innerView.computeVerticalScrollRange();
        }
    } else if(component instanceof WXScroller) {
        WXScroller scroller = (WXScroller) component;
        if(!ViewUtils.isVerticalScroller(scroller)) {
            return view.getMeasuredHeight();
        }
        ViewGroup group = scroller.getInnerView();
        if(group == null) {
            return view.getMeasuredHeight();
        }
        if(group.getChildCount() != 1) {
            return view.getMeasuredHeight();
        } else {
            return group.getChildAt(0).getMeasuredHeight();
        }
    } else {
        return view.getMeasuredHeight();
    }
}
 
Example #5
Source File: WXScrollView.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
public void setWAScroller(WXScroller mWAScroller) {
  this.mWAScroller = mWAScroller;
}
 
Example #6
Source File: BounceScrollerView.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
public BounceScrollerView(Context context, int orientation, WXScroller waScroller) {
    super(context,orientation);
    init(context);
    if (getInnerView() != null)
        getInnerView().setWAScroller(waScroller);
}
 
Example #7
Source File: WXScrollView.java    From weex-uikit with MIT License 4 votes vote down vote up
public void setWAScroller(WXScroller mWAScroller) {
  this.mWAScroller = mWAScroller;
}
 
Example #8
Source File: BounceScrollerView.java    From weex-uikit with MIT License 4 votes vote down vote up
public BounceScrollerView(Context context, int orientation, WXScroller waScroller) {
    super(context,orientation);
    if (getInnerView() != null)
        getInnerView().setWAScroller(waScroller);
}
 
Example #9
Source File: ViewUtils.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
public static boolean isVerticalScroller(@NonNull WXScroller scroller) {
    return scroller.getDomObject() != null && scroller.getDomObject().getAttrs() != null
            && "vertical".equals(scroller.getDomObject().getAttrs().getScrollDirection());
}
 
Example #10
Source File: WXScrollView.java    From weex with Apache License 2.0 4 votes vote down vote up
public void setWAScroller(WXScroller mWAScroller) {
  this.mWAScroller = mWAScroller;
}
 
Example #11
Source File: BounceScrollerView.java    From weex with Apache License 2.0 4 votes vote down vote up
public BounceScrollerView(Context context, int orientation,WXScroller waScroller) {
    super(context,orientation);
    if (getInnerView() != null)
        getInnerView().setWAScroller(waScroller);
}
 
Example #12
Source File: WXRenderStatement.java    From weex with Apache License 2.0 4 votes vote down vote up
/**
 * @see com.taobao.weex.dom.WXDomStatement#scrollToDom(String, JSONObject)
 */
void scrollTo(String ref, Map<String, Object> options) {
  WXComponent component = mRegistry.get(ref);
  if (component == null) {
    return;
  }

  int offsetInt = 0;
  if (options != null) {
    String offset = options.get("offset") == null ? "0" : options.get("offset").toString();
    if (offset != null) {
      offsetInt = Integer.parseInt(offset);
    }
  }

  WXScroller scroller = component.getParentScroller();
  if (scroller == null) {
    return;
  }
  int offsetIntF = (int) WXViewUtils.getRealPxByWidth(offsetInt);
  int[] scrollerP = new int[2];
  scroller.getView().getLocationOnScreen(scrollerP);
  if (scrollerP[1] == component.getAbsoluteY() && scroller.getView() instanceof WXScrollView) {
    return;
  }

  if(scrollerP[0] == component.getAbsoluteX() && scroller.getView() instanceof WXHorizontalScrollView){
    return;
  }

  int viewYInScroller=component.getAbsoluteY();
  int viewXInScroller=component.getAbsoluteX();
  WXComponent ancestor=component;
  while((ancestor=ancestor.getParent())!=null){
    if(ancestor instanceof WXScroller){
      viewYInScroller-=ancestor.getAbsoluteY();
      viewXInScroller-=ancestor.getAbsoluteX();
    }
  }
  scroller.scrollBy(scroller.getView().getScrollX()-viewXInScroller-offsetIntF,
                    scroller.getView().getScrollY() - viewYInScroller - offsetIntF);
}
 
Example #13
Source File: WXSDKEngine.java    From weex-uikit with MIT License 3 votes vote down vote up
private static void register() {
  BatchOperationHelper batchHelper = new BatchOperationHelper(WXBridgeManager.getInstance());
  try {
    registerComponent(
      new SimpleComponentHolder(
        WXText.class,
        new WXText.Creator()
      ),
      false,
      WXBasicComponentType.TEXT
    );
    registerComponent(
      new SimpleComponentHolder(
        WXDiv.class,
        new WXDiv.Ceator()
      ),
      false,
      WXBasicComponentType.CONTAINER,
      WXBasicComponentType.DIV,
      WXBasicComponentType.HEADER,
      WXBasicComponentType.FOOTER
    );
    registerComponent(
      new SimpleComponentHolder(
        WXImage.class,
        new WXImage.Ceator()
      ),
      false,
      WXBasicComponentType.IMAGE,
      WXBasicComponentType.IMG
    );
    registerComponent(
      new SimpleComponentHolder(
        WXScroller.class,
        new WXScroller.Creator()
      ),
      false,
      WXBasicComponentType.SCROLLER
    );
    registerComponent(
      new SimpleComponentHolder(
        WXSlider.class,
        new WXSlider.Creator()
      ),
      true,
      WXBasicComponentType.SLIDER
    );
    registerComponent(
      new SimpleComponentHolder(
              WXSliderNeighbor.class,
        new WXSliderNeighbor.Creator()
      ),
      true,
      WXBasicComponentType.SLIDER_NEIGHBOR
    );
    registerComponent(SimpleListComponent.class,false,"simplelist");
    registerComponent(WXListComponent.class, false,WXBasicComponentType.LIST,WXBasicComponentType.VLIST);
    registerComponent(HorizontalListComponent.class,false,WXBasicComponentType.HLIST);
    registerComponent(WXBasicComponentType.CELL, WXCell.class, true);
    registerComponent(WXBasicComponentType.INDICATOR, WXIndicator.class, true);
    registerComponent(WXBasicComponentType.VIDEO, WXVideo.class, false);
    registerComponent(WXBasicComponentType.INPUT, WXInput.class, false);
    registerComponent(WXBasicComponentType.TEXTAREA, Textarea.class,false);
    registerComponent(WXBasicComponentType.SWITCH, WXSwitch.class, false);
    registerComponent(WXBasicComponentType.A, WXA.class, false);
    registerComponent(WXBasicComponentType.EMBED, WXEmbed.class, true);
    registerComponent(WXBasicComponentType.WEB, WXWeb.class);
    registerComponent(WXBasicComponentType.REFRESH, WXRefresh.class);
    registerComponent(WXBasicComponentType.LOADING, WXLoading.class);
    registerComponent(WXBasicComponentType.LOADING_INDICATOR, WXLoadingIndicator.class);
    registerComponent(WXBasicComponentType.HEADER, WXHeader.class);

    registerModule("modal", WXModalUIModule.class, false);
    registerModule("instanceWrap", WXInstanceWrap.class, true);
    registerModule("animation", WXAnimationModule.class, true);
    registerModule("webview", WXWebViewModule.class, true);
    registerModule("navigator", WXNavigatorModule.class);
    registerModule("stream", WXStreamModule.class);
    registerModule("timer", WXTimerModule.class, true);
    registerModule("storage", WXStorageModule.class, true);
    registerModule("clipboard", WXClipboardModule.class, true);
    registerModule("globalEvent",WXGlobalEventModule.class);
    registerModule("picker", WXPickersModule.class);
    registerModule("meta", WXMetaModule.class,true);
    registerModule("webSocket", WebSocketModule.class);


    registerDomObject(WXBasicComponentType.INDICATOR, WXIndicator.IndicatorDomNode.class);
    registerDomObject(WXBasicComponentType.TEXT, WXTextDomObject.class);
    registerDomObject(WXBasicComponentType.INPUT, BasicEditTextDomObject.class);
    registerDomObject(WXBasicComponentType.TEXTAREA, TextAreaEditTextDomObject.class);
    registerDomObject(WXBasicComponentType.SWITCH, WXSwitchDomObject.class);
    registerDomObject(WXBasicComponentType.LIST, WXListDomObject.class);
    registerDomObject(WXBasicComponentType.VLIST, WXListDomObject.class);
    registerDomObject(WXBasicComponentType.HLIST, WXListDomObject.class);
    registerDomObject(WXBasicComponentType.SCROLLER, WXScrollerDomObject.class);
  } catch (WXException e) {
    WXLogUtils.e("[WXSDKEngine] register:", e);
  }
  batchHelper.flush();
}