diff options
author | Svetoslav <svetoslavganov@google.com> | 2014-09-17 15:45:16 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2014-09-17 23:03:19 +0000 |
commit | 0d2d9637ed4f46062d508cfa7da0e9776fc444f8 (patch) | |
tree | 5b4e19de596c79f8232feff40ef754205f711afe /packages | |
parent | a434bf303a1d73718b559c95d6d2b14d4ff482fc (diff) | |
download | frameworks_base-0d2d9637ed4f46062d508cfa7da0e9776fc444f8.zip frameworks_base-0d2d9637ed4f46062d508cfa7da0e9776fc444f8.tar.gz frameworks_base-0d2d9637ed4f46062d508cfa7da0e9776fc444f8.tar.bz2 |
Page content sometimes missing in preview when scrolling.
Removed the restriction for the page content providers to
be singletons as the RecyclerView may hold on views with
providers and ask us to bind other views for the same page.
Note that the views that RecyclerView is holding will be
soon rebound or recycled just they are not at the time we
bind other views for the same position. We were guarding
against this but caused some pages not appearing sometimes
on scrolling. Also now keeping the media size and magins
of recycled page view (will be updated if needed on
rebinding) or avoid changes of the background to null as
setting it to not null later causes an undesired layout pass.
bug:17537922
Change-Id: If029f6c413e15d4f5c1ba1ac5e4d52ad2cad5904
Diffstat (limited to 'packages')
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java | 21 | ||||
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java | 15 |
2 files changed, 5 insertions, 31 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java index 0bec217..a4555f1 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java +++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java @@ -64,9 +64,6 @@ public final class PageContentRepository { private final CloseGuard mCloseGuard = CloseGuard.get(); - private final ArrayMap<Integer, PageContentProvider> mPageContentProviders = - new ArrayMap<>(); - private final AsyncRenderer mRenderer; private RenderSpec mLastRenderSpec; @@ -141,10 +138,6 @@ public final class PageContentRepository { return mRenderer.getPageCount(); } - public PageContentProvider peekPageContentProvider(int pageIndex) { - return mPageContentProviders.get(pageIndex); - } - public PageContentProvider acquirePageContentProvider(int pageIndex, View owner) { throwIfDestroyed(); @@ -152,15 +145,7 @@ public final class PageContentRepository { Log.i(LOG_TAG, "Acquiring provider for page: " + pageIndex); } - if (mPageContentProviders.get(pageIndex)!= null) { - throw new IllegalStateException("Already acquired for page: " + pageIndex); - } - - PageContentProvider provider = new PageContentProvider(pageIndex, owner); - - mPageContentProviders.put(pageIndex, provider); - - return provider; + return new PageContentProvider(pageIndex, owner); } public void releasePageContentProvider(PageContentProvider provider) { @@ -170,10 +155,6 @@ public final class PageContentRepository { Log.i(LOG_TAG, "Releasing provider for page: " + provider.mPageIndex); } - if (mPageContentProviders.remove(provider.mPageIndex) == null) { - throw new IllegalStateException("Not acquired"); - } - provider.cancelLoad(); } diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java index 84bbc27..da8160a 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java @@ -274,8 +274,7 @@ public final class PageAdapter extends Adapter implements @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View page = mLayoutInflater.inflate(R.layout.preview_page, parent, false); - ViewHolder holder = new MyViewHolder(page); - return holder; + return new MyViewHolder(page); } @Override @@ -313,14 +312,8 @@ public final class PageAdapter extends Adapter implements + ", pageIndexInFile: " + pageIndexInFile); } - // OK, there are bugs in recycler view which tries to bind views - // without recycling them which would give us a chance to clean up. - PageContentProvider boundProvider = mPageContentRepository - .peekPageContentProvider(pageIndexInFile); - if (boundProvider != null) { - PageContentView owner = (PageContentView) boundProvider.getOwner(); - owner.init(null, mEmptyState, mMediaSize, mMinMargins); - mPageContentRepository.releasePageContentProvider(boundProvider); + if (provider != null && provider.getPageIndex() != pageIndexInFile) { + mPageContentRepository.releasePageContentProvider(provider); } provider = mPageContentRepository.acquirePageContentProvider( @@ -731,7 +724,7 @@ public final class PageAdapter extends Adapter implements private void recyclePageView(PageContentView page, int pageIndexInAdapter) { PageContentProvider provider = page.getPageContentProvider(); if (provider != null) { - page.init(null, null, null, null); + page.init(null, mEmptyState, mMediaSize, mMinMargins); mPageContentRepository.releasePageContentProvider(provider); } mBoundPagesInAdapter.remove(pageIndexInAdapter); |