コード例 #1
0
  @Override
  public ViewState process() {
    if (model == null) {
      return null;
    }

    final int pageCount = model.getPageCount();
    if (viewIndex < 0 && viewIndex >= pageCount) {
      if (LCTX.isDebugEnabled()) {
        LCTX.d("Bad page index: " + viewIndex + ", page count: " + pageCount);
      }
      return viewState;
    }

    final Page page = model.getPageObject(viewIndex);
    if (page == null) {
      if (LCTX.isDebugEnabled()) {
        LCTX.d("No page found for index: " + viewIndex);
      }
      return viewState;
    }

    model.setCurrentPageIndex(page.index);

    final IView view = ctrl.getView();

    final int scrollX = view.getScrollX();
    final int scrollY = view.getScrollY();

    final PointF p = calculateScroll(page, scrollX, scrollY);
    final int left = Math.round(p.x);
    final int top = Math.round(p.y);

    if (isScrollRequired(left, top, scrollX, scrollY)) {
      view.forceFinishScroll();
      view.scrollTo(left, top);
      viewState.update();
      return viewState;
    }
    viewState.release();

    return EventPool.newEventScrollTo(ctrl, viewIndex).process();
  }
コード例 #2
0
ファイル: DocumentModel.java プロジェクト: BetterManZ/iBooks
 public void setCurrentPageByFirstVisible(final int firstVisiblePage) {
   final Page page = getPageObject(firstVisiblePage);
   if (page != null) {
     setCurrentPageIndex(page.index);
   }
 }