diff options
author | Svetoslav <svetoslavganov@google.com> | 2014-09-16 14:41:17 -0700 |
---|---|---|
committer | Svetoslav <svetoslavganov@google.com> | 2014-09-17 11:11:08 -0700 |
commit | 7fd5ada98aa9e035682531d9fe25633fdd24a058 (patch) | |
tree | 277bf1633c286d44150f4785da16d5d0284945ec | |
parent | 386831dc3cab38552501724c7c88ae1f3ab1c80a (diff) | |
download | frameworks_base-7fd5ada98aa9e035682531d9fe25633fdd24a058.zip frameworks_base-7fd5ada98aa9e035682531d9fe25633fdd24a058.tar.gz frameworks_base-7fd5ada98aa9e035682531d9fe25633fdd24a058.tar.bz2 |
Page content sometimes disappears when scrolling a long doc in print preview.
The operations of the remote renderer have to be performed in order, open,
render some pages, close. One of the tasks was executed on the wrong executor
resuling in a race and an occassional bad state.
Also fixed a NPE if the preview list is flinged and then the user presses
back.
bug:17537922
Change-Id: I5048078ba2b875a2a8335f3a4324afaa34d014a2
5 files changed, 10 insertions, 12 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java index 14c41da..0bec217 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java +++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java @@ -526,7 +526,7 @@ public final class PageContentRepository { callback.run(); } } - }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, (Void[]) null); + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } public void close(final Runnable callback) { @@ -552,7 +552,7 @@ public final class PageContentRepository { callback.run(); } } - }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } public void destroy() { @@ -571,7 +571,7 @@ public final class PageContentRepository { mPageContentCache.invalidate(); mPageContentCache.clear(); } - }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, (Void[]) null); + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } public void startPreload(int firstShownPage, int lastShownPage, RenderSpec renderSpec) { @@ -687,7 +687,7 @@ public final class PageContentRepository { // Oh well, we will have work to do... renderTask = new RenderPageTask(pageIndex, renderSpec, callback); mPageToRenderTaskMap.put(pageIndex, renderTask); - renderTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, (Void[]) null); + renderTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } public void cancelRendering(int pageIndex) { diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java index 369c453..84bbc27 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java @@ -275,7 +275,6 @@ public final class PageAdapter extends Adapter implements public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View page = mLayoutInflater.inflate(R.layout.preview_page, parent, false); ViewHolder holder = new MyViewHolder(page); - holder.setIsRecyclable(true); return holder; } diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java index 389988a..d169319 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java @@ -953,7 +953,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat // When the update is done we update the print preview. mProgressMessageController.post(); return true; - } else { + } else if (!willUpdate) { // Update preview. updatePrintPreviewController(false); } diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java index b999866..0d45352 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java @@ -77,6 +77,7 @@ class PrintPreviewController implements MutexFileProvider.OnReleaseRequestCallba mRecyclerView = (RecyclerView) activity.findViewById(R.id.preview_content); mRecyclerView.setLayoutManager(mLayoutManger); mRecyclerView.setAdapter(mPageAdapter); + mRecyclerView.setItemViewCacheSize(0); mPreloadController = new PreloadController(mRecyclerView); mRecyclerView.setOnScrollListener(mPreloadController); @@ -348,8 +349,7 @@ class PrintPreviewController implements MutexFileProvider.OnReleaseRequestCallba public void startPreloadContent() { PageAdapter pageAdapter = (PageAdapter) mRecyclerView.getAdapter(); - - if (pageAdapter.isOpened()) { + if (pageAdapter != null && pageAdapter.isOpened()) { PageRange shownPages = computeShownPages(); if (shownPages != null) { pageAdapter.startPreloadContent(shownPages); @@ -359,8 +359,7 @@ class PrintPreviewController implements MutexFileProvider.OnReleaseRequestCallba public void stopPreloadContent() { PageAdapter pageAdapter = (PageAdapter) mRecyclerView.getAdapter(); - - if (pageAdapter.isOpened()) { + if (pageAdapter != null && pageAdapter.isOpened()) { pageAdapter.stopPreloadContent(); } } diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java index 1000117..b792789 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java +++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java @@ -52,12 +52,12 @@ public class PageContentView extends View @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { + mContentRequested = false; requestPageContentIfNeeded(); } @Override public void onPageContentAvailable(BitmapDrawable content) { - assert (getBackground() != content); setBackground(content); } @@ -70,7 +70,7 @@ public class PageContentView extends View final boolean providerChanged = (mProvider == null) ? provider != null : !mProvider.equals(provider); final boolean loadingDrawableChanged = (mEmptyState == null) - ? mEmptyState != null : !mEmptyState.equals(emptyState); + ? emptyState != null : !mEmptyState.equals(emptyState); final boolean mediaSizeChanged = (mMediaSize == null) ? mediaSize != null : !mMediaSize.equals(mediaSize); final boolean marginsChanged = (mMinMargins == null) |