FileDocCategorySizeDatePackage
PageContentView.javaAPI DocAndroid 5.1 API3846Thu Mar 12 22:22:42 GMT 2015com.android.printspooler.widget

PageContentView

public class PageContentView extends android.view.View implements PageContentRepository.OnPageContentAvailableCallback
This class represents a page in the print preview list. The width of the page is determined by stretching it to take maximal horizontal space while the height is computed from the width using the page aspect ratio. Note that different media sizes have different aspect ratios.

Fields Summary
private com.android.printspooler.model.PageContentRepository.PageContentProvider
mProvider
private android.print.PrintAttributes.MediaSize
mMediaSize
private android.print.PrintAttributes.Margins
mMinMargins
private android.graphics.drawable.Drawable
mEmptyState
private boolean
mContentRequested
Constructors Summary
public PageContentView(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
    
Methods Summary
public com.android.printspooler.model.PageContentRepository.PageContentProvidergetPageContentProvider()

        return mProvider;
    
public voidinit(com.android.printspooler.model.PageContentRepository.PageContentProvider provider, android.graphics.drawable.Drawable emptyState, android.print.PrintAttributes.MediaSize mediaSize, android.print.PrintAttributes.Margins minMargins)

        final boolean providerChanged = (mProvider == null)
                ? provider != null : !mProvider.equals(provider);
        final boolean loadingDrawableChanged = (mEmptyState == null)
                ? emptyState != null : !mEmptyState.equals(emptyState);
        final boolean mediaSizeChanged = (mMediaSize == null)
                ? mediaSize != null : !mMediaSize.equals(mediaSize);
        final boolean marginsChanged = (mMinMargins == null)
                ? minMargins != null : !mMinMargins.equals(minMargins);

        if (!providerChanged && !mediaSizeChanged
                && !marginsChanged && !loadingDrawableChanged) {
            return;
        }

        mProvider = provider;
        mMediaSize = mediaSize;
        mMinMargins = minMargins;

        mEmptyState = emptyState;
        mContentRequested = false;

        // If there is no provider we want immediately to switch to
        // the empty state, so pages with no content appear blank.
        if (mProvider == null && getBackground() != mEmptyState) {
            setBackground(mEmptyState);
        }

        requestPageContentIfNeeded();
    
public voidonPageContentAvailable(android.graphics.drawable.BitmapDrawable content)

        setBackground(content);
    
protected voidonSizeChanged(int w, int h, int oldw, int oldh)

        mContentRequested = false;
        requestPageContentIfNeeded();
    
private voidrequestPageContentIfNeeded()

        if (getWidth() > 0 && getHeight() > 0 && !mContentRequested
                && mProvider != null) {
            mContentRequested = true;
            mProvider.getPageContent(new RenderSpec(getWidth(), getHeight(),
                    mMediaSize, mMinMargins), this);
        }