Search in sources :

Example 1 with Bitmaps

use of org.ebookdroid.common.bitmaps.Bitmaps 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)

Example 2 with Bitmaps

use of org.ebookdroid.common.bitmaps.Bitmaps in project LibreraReader by foobnix.

the class DocumentModel method recyclePages.

public void recyclePages() {
    if (LengthUtils.isNotEmpty(pages)) {
        final List<Bitmaps> bitmapsToRecycle = new ArrayList<Bitmaps>();
        for (final Page page : pages) {
            page.recycle(bitmapsToRecycle);
        }
        BitmapManager.release(bitmapsToRecycle);
        BitmapManager.release();
    }
    pages = EMPTY_PAGES;
}
Also used : ArrayList(java.util.ArrayList) Bitmaps(org.ebookdroid.common.bitmaps.Bitmaps) Page(org.ebookdroid.core.Page)

Aggregations

Bitmaps (org.ebookdroid.common.bitmaps.Bitmaps)2 ArrayList (java.util.ArrayList)1 Page (org.ebookdroid.core.Page)1 IViewController (org.ebookdroid.ui.viewer.IViewController)1