Java Code Examples for com.taobao.weex.ui.component.WXComponent#getParentScroller()

The following examples show how to use com.taobao.weex.ui.component.WXComponent#getParentScroller() . 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: WXStickyHelper.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public void bindStickStyle(WXComponent component, Map<String, Map<String, WXComponent>> mStickyMap) {
    Scrollable scroller = component.getParentScroller();
    if (scroller == null) {
        return;
    }
    Map<String, WXComponent> stickyMap = mStickyMap.get(scroller
            .getRef());
    if (stickyMap == null) {
        stickyMap = new ConcurrentHashMap<>();
    }
    if (stickyMap.containsKey(component.getRef())) {
        return;
    }
    stickyMap.put(component.getRef(), component);
    mStickyMap.put(scroller.getRef(), stickyMap);
}
 
Example 2
Source File: WXRenderStatement.java    From weex-uikit with MIT License 6 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;
  }

  float offsetFloat = 0;
  if (options != null) {
    String offset = options.get("offset") == null ? "0" : options.get("offset").toString();
    if (offset != null) {
      try {
        offsetFloat = WXViewUtils.getRealPxByWidth(Float.parseFloat(offset),mWXSDKInstance.getViewPortWidth());
      }catch (Exception e ){
         WXLogUtils.e("Float parseFloat error :"+e.getMessage());
      }
    }
  }

  Scrollable scroller = component.getParentScroller();
  if (scroller == null) {
    return;
  }
  scroller.scrollTo(component,(int)offsetFloat);
}
 
Example 3
Source File: WXStickyHelper.java    From weex-uikit with MIT License 6 votes vote down vote up
public void bindStickStyle(WXComponent component, Map<String, HashMap<String, WXComponent>> mStickyMap) {
    Scrollable scroller = component.getParentScroller();
    if (scroller == null) {
        return;
    }
    HashMap<String, WXComponent> stickyMap = mStickyMap.get(scroller
            .getRef());
    if (stickyMap == null) {
        stickyMap = new HashMap<>();
    }
    if (stickyMap.containsKey(component.getRef())) {
        return;
    }
    stickyMap.put(component.getRef(), component);
    mStickyMap.put(scroller.getRef(), stickyMap);
}
 
Example 4
Source File: ScrollToElementAction.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void executeRender(RenderActionContext context) {
  WXComponent component = context.getComponent(mRef);
  if (component == null) {
    return;
  }

  Scrollable scroller = component.getParentScroller();
  if (scroller == null) {
    return;
  }
  scroller.scrollTo(component,mOptions);
}
 
Example 5
Source File: WXGesture.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public WXGesture(WXComponent wxComponent, Context context) {
  this.component = wxComponent;
  globalRect = new Rect();
  globalOffset = new Point();
  globalEventOffset = new Point();
  locEventOffset = new PointF();
  locLeftTop = new PointF();
  mGestureDetector = new GestureDetector(context, this, new GestureHandler());
  Scrollable parentScrollable = wxComponent.getParentScroller();
  if(parentScrollable != null) {
    mParentOrientation = parentScrollable.getOrientation();
  }
}
 
Example 6
Source File: WXStickyHelper.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public void unbindStickStyle(WXComponent component, Map<String, Map<String, WXComponent>> mStickyMap) {
    Scrollable scroller = component.getParentScroller();
    if (scroller == null) {
        return;
    }
    Map<String, WXComponent> stickyMap = mStickyMap.get(scroller
            .getRef());
    if (stickyMap == null) {
        return;
    }
    stickyMap.remove(component.getRef());
}
 
Example 7
Source File: WXStickyHelper.java    From weex-uikit with MIT License 5 votes vote down vote up
public void unbindStickStyle(WXComponent component, Map<String, HashMap<String, WXComponent>> mStickyMap) {
    Scrollable scroller = component.getParentScroller();
    if (scroller == null) {
        return;
    }
    HashMap<String, WXComponent> stickyMap = mStickyMap.get(scroller
            .getRef());
    if (stickyMap == null) {
        return;
    }
    stickyMap.remove(component.getRef());
}
 
Example 8
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);
}