Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3f963b0 authored by Svetoslav's avatar Svetoslav
Browse files

Missing or wrong pages in preview when scorlling large docs.

The bound pages in the adapter were not properly tracked, more
specifically we did not remove pages from the bound set ending
up in a bad state. Also when the printer changes and if the
new one has different page size the content disappears due to
us not notifying for the data set change.

bug:17515670

Change-Id: Iac74e864609012f6804584fa133e87c27dc186a5
parent f230c5d2
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public final class PageAdapter extends Adapter implements

    private static final int MAX_PREVIEW_PAGES_BATCH = 50;

    private static final boolean DEBUG = true;
    private static final boolean DEBUG = false;

    private static final PageRange[] ALL_PAGES_ARRAY = new PageRange[] {
            PageRange.ALL_PAGES
@@ -175,13 +175,19 @@ public final class PageAdapter extends Adapter implements
        return mPageContentRepository.getFilePageCount();
    }

    public void open(ParcelFileDescriptor source, Runnable callback) {
    public void open(ParcelFileDescriptor source, final Runnable callback) {
        throwIfNotClosed();
        mState = STATE_OPENED;
        if (DEBUG) {
            Log.i(LOG_TAG, "STATE_OPENED");
        }
        mPageContentRepository.open(source, callback);
        mPageContentRepository.open(source, new Runnable() {
            @Override
            public void run() {
                notifyDataSetChanged();
                callback.run();
            }
        });
    }

    public void update(PageRange[] writtenPages, PageRange[] selectedPages,
@@ -728,8 +734,8 @@ public final class PageAdapter extends Adapter implements
        if (provider != null) {
            page.init(null, null, null, null);
            mPageContentRepository.releasePageContentProvider(provider);
            mBoundPagesInAdapter.remove(pageIndexInAdapter);
        }
        mBoundPagesInAdapter.remove(pageIndexInAdapter);
        page.setTag(null);
    }

+2 −4
Original line number Diff line number Diff line
@@ -25,11 +25,9 @@ import android.print.PrintAttributes.MediaSize;
import android.print.PrintAttributes.Margins;
import android.print.PrintDocumentInfo;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.support.v7.widget.RecyclerView.LayoutManager;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import com.android.internal.os.SomeArgs;
import com.android.printspooler.R;
@@ -153,7 +151,7 @@ class PrintPreviewController implements MutexFileProvider.OnReleaseRequestCallba

        // The content changed. In this case we have to invalidate
        // all rendered pages and reopen the file...
        if (contentChanged && writtenPages != null) {
        if ((contentChanged || !mPageAdapter.isOpened()) && writtenPages != null) {
            Message operation = mHandler.obtainMessage(MyHandler.MSG_OPEN);
            mHandler.enqueueOperation(operation);
        }