Search in sources :

Example 1 with PageAlign

use of org.ebookdroid.common.settings.types.PageAlign in project LibreraReader by foobnix.

the class VScrollController method invalidatePageSizes.

/**
 * {@inheritDoc}
 *
 * @see org.ebookdroid.ui.viewer.IViewController#invalidatePageSizes(org.ebookdroid.ui.viewer.IViewController.InvalidateSizeReason,
 *      org.ebookdroid.core.Page)
 */
@Override
public final synchronized void invalidatePageSizes(final InvalidateSizeReason reason, final Page changedPage) {
    if (!isInitialized) {
        return;
    }
    if (reason == InvalidateSizeReason.PAGE_ALIGN) {
        return;
    }
    final int width = getWidth();
    final int height = getHeight();
    final BookSettings bookSettings = SettingsManager.getBookSettings();
    final PageAlign pageAlign = DocumentViewMode.getPageAlign(bookSettings);
    if (changedPage == null) {
        float heightAccum = 0;
        for (final Page page : model.getPages()) {
            final RectF pageBounds = calcPageBounds(pageAlign, page.getAspectRatio(), width, height);
            pageBounds.offset(0, heightAccum);
            page.setBounds(pageBounds);
            heightAccum += pageBounds.height() + 3;
        }
    } else {
        float heightAccum = changedPage.getBounds(1.0f).top;
        for (final Page page : model.getPages(changedPage.index.viewIndex)) {
            final RectF pageBounds = calcPageBounds(pageAlign, page.getAspectRatio(), width, height);
            pageBounds.offset(0, heightAccum);
            page.setBounds(pageBounds);
            heightAccum += pageBounds.height() + 3;
        }
    }
}
Also used : PageAlign(org.ebookdroid.common.settings.types.PageAlign) RectF(android.graphics.RectF) BookSettings(org.ebookdroid.common.settings.books.BookSettings)

Example 2 with PageAlign

use of org.ebookdroid.common.settings.types.PageAlign in project LibreraReader by foobnix.

the class HScrollController method invalidatePageSizes.

/**
 * {@inheritDoc}
 *
 * @see org.ebookdroid.ui.viewer.IViewController#invalidatePageSizes(org.ebookdroid.ui.viewer.IViewController.InvalidateSizeReason,
 *      org.ebookdroid.core.Page)
 */
@Override
public final synchronized void invalidatePageSizes(final InvalidateSizeReason reason, final Page changedPage) {
    if (!isInitialized) {
        return;
    }
    if (reason == InvalidateSizeReason.PAGE_ALIGN) {
        return;
    }
    final int height = getHeight();
    final int width = getWidth();
    final BookSettings bookSettings = SettingsManager.getBookSettings();
    final PageAlign pageAlign = DocumentViewMode.getPageAlign(bookSettings);
    if (changedPage == null) {
        float widthAccum = 0;
        for (final Page page : model.getPages()) {
            final RectF pageBounds = calcPageBounds(pageAlign, page.getAspectRatio(), width, height);
            pageBounds.offset(widthAccum, 0);
            page.setBounds(pageBounds);
            widthAccum += pageBounds.width() + 3;
        }
    } else {
        float widthAccum = changedPage.getBounds(1.0f).left;
        for (final Page page : model.getPages(changedPage.index.viewIndex)) {
            final RectF pageBounds = calcPageBounds(pageAlign, page.getAspectRatio(), width, height);
            pageBounds.offset(widthAccum, 0);
            page.setBounds(pageBounds);
            widthAccum += pageBounds.width() + 3;
        }
    }
}
Also used : PageAlign(org.ebookdroid.common.settings.types.PageAlign) RectF(android.graphics.RectF) BookSettings(org.ebookdroid.common.settings.books.BookSettings)

Aggregations

RectF (android.graphics.RectF)2 BookSettings (org.ebookdroid.common.settings.books.BookSettings)2 PageAlign (org.ebookdroid.common.settings.types.PageAlign)2