PageContentViewpublic class PageContentView extends android.view.View implements PageContentRepository.OnPageContentAvailableCallbackThis 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 |
Methods Summary |
---|
public com.android.printspooler.model.PageContentRepository.PageContentProvider | getPageContentProvider()
return mProvider;
| public void | init(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 void | onPageContentAvailable(android.graphics.drawable.BitmapDrawable content)
setBackground(content);
| protected void | onSizeChanged(int w, int h, int oldw, int oldh)
mContentRequested = false;
requestPageContentIfNeeded();
| private void | requestPageContentIfNeeded()
if (getWidth() > 0 && getHeight() > 0 && !mContentRequested
&& mProvider != null) {
mContentRequested = true;
mProvider.getPageContent(new RenderSpec(getWidth(), getHeight(),
mMediaSize, mMinMargins), this);
}
|
|