Search in sources :

Example 1 with IViewController

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

the class PdfSurfaceView method scrollTo.

/**
 * {@inheritDoc}
 *
 * @see org.ebookdroid.ui.viewer.IView#scrollTo(int, int)
 */
@Override
public final void scrollTo(final int x, final int y) {
    final Runnable r = new Runnable() {

        @Override
        public void run() {
            final IViewController dc = base.getDocumentController();
            final Rect l = dc.getScrollLimits();
            final int xx = MathUtils.adjust(x, l.left, l.right);
            final int yy = MathUtils.adjust(y, l.top, l.bottom);
            PdfSurfaceView.super.scrollTo(xx, yy);
        }
    };
    base.getActivity().runOnUiThread(r);
}
Also used : Rect(android.graphics.Rect) IViewController(org.ebookdroid.ui.viewer.IViewController)

Example 2 with IViewController

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

the class PageTreeNode method decodeComplete.

@Override
public void decodeComplete(final CodecPage codecPage, final BitmapRef bitmap, final Rect bitmapBounds, final RectF croppedPageBounds) {
    try {
        if (bitmap == null || bitmapBounds == null) {
            page.base.getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    stopDecodingThisNode(null);
                }
            });
            return;
        }
        final Bitmaps bitmaps = holder.reuse(fullId, bitmap, bitmapBounds);
        final Runnable r = new Runnable() {

            @Override
            public void run() {
                // long t0 = System.currentTimeMillis();
                holder.setBitmap(bitmaps);
                stopDecodingThisNode(null);
                final IViewController dc = page.base.getDocumentController();
                if (dc instanceof AbstractViewController) {
                    EventPool.newEventChildLoaded((AbstractViewController) dc, PageTreeNode.this, bitmapBounds).process();
                }
            // System.out.println("decodeComplete(): " + (System.currentTimeMillis() - t0) + " ms");
            }
        };
        page.base.getActivity().runOnUiThread(r);
    } catch (final OutOfMemoryError ex) {
        ex.printStackTrace();
        BitmapManager.clear("PageTreeNode OutOfMemoryError: ");
        page.base.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                stopDecodingThisNode(null);
            }
        });
    } finally {
        BitmapManager.release(bitmap);
    }
}
Also used : Bitmaps(org.ebookdroid.common.bitmaps.Bitmaps) IViewController(org.ebookdroid.ui.viewer.IViewController)

Aggregations

IViewController (org.ebookdroid.ui.viewer.IViewController)2 Rect (android.graphics.Rect)1 Bitmaps (org.ebookdroid.common.bitmaps.Bitmaps)1