OSDN Git Service

The PageAdapter update might be caused by the RecylerView.
authorPhilip P. Moltmann <moltmann@google.com>
Wed, 16 Mar 2016 23:24:38 +0000 (16:24 -0700)
committerPhilip P. Moltmann <moltmann@google.com>
Wed, 16 Mar 2016 23:24:38 +0000 (16:24 -0700)
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

packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java

index 606f4eb..645e182 100644 (file)
@@ -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,7 +572,14 @@ public final class PageAdapter extends Adapter<ViewHolder> {
             if (DEBUG) {
                 Log.i(LOG_TAG, "Requesting pages: " + Arrays.toString(mRequestedPages));
             }
-            mCallbacks.onRequestContentUpdate();
+
+            // 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();
+                }
+            });
         }
     }