From e6ecba59fd618b80dd13f581b625eea420672a0a Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Fri, 12 Sep 2014 14:15:33 -0700 Subject: [PATCH] Page content sometimes missing while scrolling. The logic when a page view to request the content had a logical error and it was getting in a bad state where it never requested the content anymore. This change simplifies the logic and minimizes the kept state. Removed unnecessary calls to recycle for a bitmap as according to the graphics folks we should not be calling this API anymore. bug:16966145 Change-Id: Idda8314b43343136d3b867167261790481116fac --- .../printspooler/model/PageContentRepository.java | 8 +------- .../com/android/printspooler/widget/PageContentView.java | 9 ++------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java index 1d8261b43ec0a..14c41dadb0ba6 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java +++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java @@ -345,7 +345,7 @@ public final class PageContentRepository { Iterator> iterator = mRenderedPages.entrySet().iterator(); while (iterator.hasNext()) { - iterator.next().getValue().recycle(); + iterator.next(); iterator.remove(); } } @@ -425,10 +425,6 @@ public final class PageContentRepository { return content.getBitmap().getByteCount(); } - public void recycle() { - content.getBitmap().recycle(); - } - public void erase() { content.getBitmap().eraseColor(Color.WHITE); } @@ -738,7 +734,6 @@ public final class PageContentRepository { + " with different size."); } mPageContentCache.removeRenderedPage(mPageIndex); - mRenderedPage.recycle(); mRenderedPage = null; } @@ -762,7 +757,6 @@ public final class PageContentRepository { Log.i(LOG_TAG, "Recycling bitmap for page: " + mPageIndex + " with different size."); } - renderedPage.recycle(); continue; } diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java index c22c0e2fe2659..100011738c47c 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java +++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java @@ -46,16 +46,12 @@ public class PageContentView extends View private boolean mContentRequested; - private boolean mNeedsLayout; - public PageContentView(Context context, AttributeSet attrs) { super(context, attrs); } @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - mNeedsLayout = false; + protected void onSizeChanged(int w, int h, int oldw, int oldh) { requestPageContentIfNeeded(); } @@ -91,7 +87,6 @@ public class PageContentView extends View mEmptyState = emptyState; mContentRequested = false; - mNeedsLayout = mNeedsLayout || mediaSizeChanged || marginsChanged; // If there is no provider we want immediately to switch to // the empty state, so pages with no content appear blank. @@ -104,7 +99,7 @@ public class PageContentView extends View private void requestPageContentIfNeeded() { if (getWidth() > 0 && getHeight() > 0 && !mContentRequested - && mProvider != null && !mNeedsLayout) { + && mProvider != null) { mContentRequested = true; mProvider.getPageContent(new RenderSpec(getWidth(), getHeight(), mMediaSize, mMinMargins), this);