FileDocCategorySizeDatePackage
PageContentRepository.javaAPI DocAndroid 5.1 API32141Thu Mar 12 22:22:42 GMT 2015com.android.printspooler.model

PageContentRepository

public final class PageContentRepository extends Object

Fields Summary
private static final String
LOG_TAG
private static final boolean
DEBUG
private static final int
INVALID_PAGE_INDEX
private static final int
STATE_CLOSED
private static final int
STATE_OPENED
private static final int
STATE_DESTROYED
private static final int
BYTES_PER_PIXEL
private static final int
BYTES_PER_MEGABYTE
private final dalvik.system.CloseGuard
mCloseGuard
private final AsyncRenderer
mRenderer
private RenderSpec
mLastRenderSpec
private int
mScheduledPreloadFirstShownPage
private int
mScheduledPreloadLastShownPage
private int
mState
Constructors Summary
public PageContentRepository(android.content.Context context)


       
           
    

       
        mRenderer = new AsyncRenderer(context);
        mState = STATE_CLOSED;
        if (DEBUG) {
            Log.i(LOG_TAG, "STATE_CLOSED");
        }
        mCloseGuard.open("destroy");
    
Methods Summary
public com.android.printspooler.model.PageContentRepository$PageContentProvideracquirePageContentProvider(int pageIndex, android.view.View owner)

        throwIfDestroyed();

        if (DEBUG) {
            Log.i(LOG_TAG, "Acquiring provider for page: " + pageIndex);
        }

        return new PageContentProvider(pageIndex, owner);
    
public voidclose(java.lang.Runnable callback)

        throwIfNotOpened();
        mState = STATE_CLOSED;
        if (DEBUG) {
            Log.i(LOG_TAG, "STATE_CLOSED");
        }

        mRenderer.close(callback);
    
public voiddestroy(java.lang.Runnable callback)

        if (mState == STATE_OPENED) {
            close(new Runnable() {
                @Override
                public void run() {
                    destroy(callback);
                }
            });
            return;
        }

        mState = STATE_DESTROYED;
        if (DEBUG) {
            Log.i(LOG_TAG, "STATE_DESTROYED");
        }
        mRenderer.destroy();

        if (callback != null) {
            callback.run();
        }
    
protected voidfinalize()

        try {
            if (mState != STATE_DESTROYED) {
                mCloseGuard.warnIfOpen();
                destroy(null);
            }
        } finally {
            super.finalize();
        }
    
public intgetFilePageCount()

        return mRenderer.getPageCount();
    
public voidopen(android.os.ParcelFileDescriptor source, OpenDocumentCallback callback)

        throwIfNotClosed();
        mState = STATE_OPENED;
        if (DEBUG) {
            Log.i(LOG_TAG, "STATE_OPENED");
        }
        mRenderer.open(source, callback);
    
public voidreleasePageContentProvider(com.android.printspooler.model.PageContentRepository$PageContentProvider provider)

        throwIfDestroyed();

        if (DEBUG) {
            Log.i(LOG_TAG, "Releasing provider for page: " + provider.mPageIndex);
        }

        provider.cancelLoad();
    
public voidstartPreload(int firstShownPage, int lastShownPage)

        // If we do not have a render spec we have no clue what size the
        // preloaded bitmaps should be, so just take a note for what to do.
        if (mLastRenderSpec == null) {
            mScheduledPreloadFirstShownPage = firstShownPage;
            mScheduledPreloadLastShownPage = lastShownPage;
        } else if (mState == STATE_OPENED) {
            mRenderer.startPreload(firstShownPage, lastShownPage, mLastRenderSpec);
        }
    
public voidstopPreload()

        mRenderer.stopPreload();
    
private voidthrowIfDestroyed()

        if (mState == STATE_DESTROYED) {
            throw new IllegalStateException("Destroyed");
        }
    
private voidthrowIfNotClosed()

        if (mState != STATE_CLOSED) {
            throw new IllegalStateException("Not closed");
        }
    
private voidthrowIfNotOpened()

        if (mState != STATE_OPENED) {
            throw new IllegalStateException("Not opened");
        }