Java Code Examples for android.support.v7.widget.RecyclerView#computeHorizontalScrollRange()

The following examples show how to use android.support.v7.widget.RecyclerView#computeHorizontalScrollRange() . 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: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
private void fireScrollEvent(RecyclerView recyclerView, int offsetX, int offsetY) {
  int contentWidth = recyclerView.getMeasuredWidth() + recyclerView.computeHorizontalScrollRange();
  int contentHeight = recyclerView.computeVerticalScrollRange();

  Map<String, Object> event = new HashMap<>(2);
  Map<String, Object> contentSize = new HashMap<>(2);
  Map<String, Object> contentOffset = new HashMap<>(2);

  contentSize.put(Constants.Name.WIDTH, WXViewUtils.getWebPxByWidth(contentWidth, getInstance().getInstanceViewPortWidth()));
  contentSize.put(Constants.Name.HEIGHT, WXViewUtils.getWebPxByWidth(contentHeight, getInstance().getInstanceViewPortWidth()));

  contentOffset.put(Constants.Name.X, - WXViewUtils.getWebPxByWidth(offsetX, getInstance().getInstanceViewPortWidth()));
  contentOffset.put(Constants.Name.Y, - WXViewUtils.getWebPxByWidth(offsetY, getInstance().getInstanceViewPortWidth()));
  event.put(Constants.Name.CONTENT_SIZE, contentSize);
  event.put(Constants.Name.CONTENT_OFFSET, contentOffset);

  fireEvent(Constants.Event.SCROLL, event);
}
 
Example 2
Source File: Utils.java    From SimpleRecyclerView with Apache License 2.0 4 votes vote down vote up
public static boolean isScrollable(RecyclerView recyclerView) {
  return recyclerView.computeHorizontalScrollRange() > recyclerView.getWidth() ||
    recyclerView.computeVerticalScrollRange() > recyclerView.getHeight();
}