Пример #1
0
  /**
   * Scrolls up and down.
   *
   * @param direction the direction in which to scroll
   * @param allTheWay <code>true</code> if the view should be scrolled to the beginning or end,
   *     <code>false</code> to scroll one page up or down.
   * @return {@code true} if more scrolling can be done
   */
  public boolean scroll(int direction, boolean allTheWay) {
    final ArrayList<View> viewList =
        RobotiumUtils.removeInvisibleViews(viewFetcher.getAllViews(true));
    @SuppressWarnings("unchecked")
    ArrayList<View> views =
        RobotiumUtils.filterViewsToSet(
            new Class[] {ListView.class, ScrollView.class, GridView.class, WebView.class},
            viewList);

    View view = viewFetcher.getFreshestView(views);
    if (view == null) {
      view = viewFetcher.getRecyclerView(0);

      if (view == null) {
        return false;
      }
    }

    if (view instanceof AbsListView) {
      return scrollList((AbsListView) view, direction, allTheWay);
    }

    if (view instanceof WebView) {
      return scrollWebView((WebView) view, direction, allTheWay);
    }

    if (allTheWay) {
      scrollViewAllTheWay(view, direction);
      return false;
    } else {
      return scrollView(view, direction);
    }
  }