Search in sources :

Example 1 with IView

use of org.ebookdroid.ui.viewer.IView in project LibreraReader by foobnix.

the class EventGotoPage method process.

@Override
public ViewState process() {
    if (model == null) {
        return null;
    }
    final int pageCount = model.getPageCount();
    if (toPageIndex < 0 && toPageIndex >= pageCount) {
        return viewState;
    }
    final Page page = model.getPageObject(toPageIndex);
    if (page == null) {
        return viewState;
    }
    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)) {
        if (animte) {
            view.startPageScroll(0, top - scrollY);
        } else {
            view.scrollTo(left, top);
        }
        return new ViewState(ctrl);
    }
    return EventPool.newEventScrollTo(ctrl, toPageIndex).process();
}
Also used : IView(org.ebookdroid.ui.viewer.IView) PointF(android.graphics.PointF)

Example 2 with IView

use of org.ebookdroid.ui.viewer.IView in project LibreraReader by foobnix.

the class ViewState method getPositionOnPage.

public final PointF getPositionOnPage(final Page page) {
    final PointF pos = new PointF();
    final IView view = ctrl.getView();
    if (view != null) {
        final int left = view.getScrollX();
        final int top = view.getScrollY();
        final RectF cpBounds = getBounds(page);
        pos.x = (left - cpBounds.left) / cpBounds.width();
        pos.y = (top - cpBounds.top) / cpBounds.height();
    }
    return pos;
}
Also used : RectF(android.graphics.RectF) IView(org.ebookdroid.ui.viewer.IView) PointF(android.graphics.PointF)

Example 3 with IView

use of org.ebookdroid.ui.viewer.IView in project LibreraReader by foobnix.

the class DocumentModel method initPages.

public void initPages(final IActivityController base, final IProgressIndicator task) {
    recyclePages();
    final BookSettings bs = SettingsManager.getBookSettings();
    if (base == null || bs == null || context == null || decodeService == null) {
        return;
    }
    final IView view = base.getView();
    final CodecPageInfo defCpi = new CodecPageInfo();
    defCpi.width = (view.getWidth());
    defCpi.height = (view.getHeight());
    int viewIndex = 0;
    try {
        final ArrayList<Page> list = new ArrayList<Page>();
        final CodecPageInfo[] infos = retrievePagesInfo(base, bs, task);
        for (int docIndex = 0; docIndex < infos.length; docIndex++) {
            if (TempHolder.get().loadingCancelled) {
                return;
            }
            if (!AppState.get().isCut) {
                CodecPageInfo cpi = infos[docIndex] != null ? infos[docIndex] : defCpi;
                final Page page = new Page(base, new PageIndex(docIndex, viewIndex++), PageType.FULL_PAGE, cpi);
                list.add(page);
            } else {
                final Page page1 = new Page(base, new PageIndex(docIndex, viewIndex++), PageType.LEFT_PAGE, infos[docIndex]);
                final Page page2 = new Page(base, new PageIndex(docIndex, viewIndex++), PageType.RIGHT_PAGE, infos[docIndex]);
                if (AppState.get().isCutRTL) {
                    list.add(page2);
                    list.add(page1);
                } else {
                    list.add(page1);
                    list.add(page2);
                }
            }
        }
        pages = list.toArray(new Page[list.size()]);
    } finally {
    }
}
Also used : IView(org.ebookdroid.ui.viewer.IView) CodecPageInfo(org.ebookdroid.core.codec.CodecPageInfo) ArrayList(java.util.ArrayList) BookSettings(org.ebookdroid.common.settings.books.BookSettings) Page(org.ebookdroid.core.Page) PageIndex(org.ebookdroid.core.PageIndex)

Aggregations

IView (org.ebookdroid.ui.viewer.IView)3 PointF (android.graphics.PointF)2 RectF (android.graphics.RectF)1 ArrayList (java.util.ArrayList)1 BookSettings (org.ebookdroid.common.settings.books.BookSettings)1 Page (org.ebookdroid.core.Page)1 PageIndex (org.ebookdroid.core.PageIndex)1 CodecPageInfo (org.ebookdroid.core.codec.CodecPageInfo)1