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

Commit e7f06a87 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

The PageAdapter update might be caused by the RecylerView.

In this case it cannot call back into the recyclerView and update the
data. For the call path please see the bug.

Bug: 27614499
Change-Id: I84733fea30429c20a2c96085efb47d4da5e1948a
parent 215fe693
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.print.PageRange;
import android.print.PrintAttributes.MediaSize;
@@ -570,8 +572,15 @@ public final class PageAdapter extends Adapter<ViewHolder> {
            if (DEBUG) {
                Log.i(LOG_TAG, "Requesting pages: " + Arrays.toString(mRequestedPages));
            }

            // This call might come from a recylerview that is currently updating. Hence delay to
            // after the update
            (new Handler(Looper.getMainLooper())).post(new Runnable() {
                @Override public void run() {
                    mCallbacks.onRequestContentUpdate();
                }
            });
        }
    }

    private PageRange[] computeRequestedPages(int pageInDocument) {