OSDN Git Service

Drag thumbnail fixes / improvements
authorChris Tate <ctate@google.com>
Thu, 14 Oct 2010 22:48:59 +0000 (15:48 -0700)
committerChris Tate <ctate@google.com>
Thu, 14 Oct 2010 23:43:39 +0000 (16:43 -0700)
* Properly wipe the thumbnail canvas before handing it to the app for
  its contents to be drawn

* Provide a getView() method in DragThumbnailBuilder that allows
  clients or subclasses to get at the associated view.  This is
  especially for clients that want to draw entire (sub)layouts as
  the drag thumbnail, by overriding onDrawThumbnail(Canvas c)
  like this:

  // Override specifically for drawing a whole ViewGroup into
  // the drag thumbnail canvas
  @Override
  public void onDrawThumbnail(Canvas c) {
      getView().dispatchDraw(c);
  }

Change-Id: Ib43ddd7cf1d44faf2d7f6ba79f102bc3c7f14596

api/current.xml
core/java/android/view/View.java

index 6677a90..0d76b71 100644 (file)
 <parameter name="view" type="android.view.View">
 </parameter>
 </constructor>
+<method name="getView"
+ return="android.view.View"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onDrawThumbnail"
  return="void"
  abstract="false"
index 8e4591a..2b63eff 100644 (file)
@@ -9854,6 +9854,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
             mView = new WeakReference<View>(view);
         }
 
+        final public View getView() {
+            return mView.get();
+        }
+
         /**
          * Provide the draggable-thumbnail metrics for the operation: the dimensions of
          * the thumbnail image itself, and the point within that thumbnail that should
@@ -9932,6 +9936,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
             if (token != null) {
                 Canvas canvas = surface.lockCanvas(null);
                 try {
+                    canvas.drawColor(0, PorterDuff.Mode.CLEAR);
                     thumbBuilder.onDrawThumbnail(canvas);
                 } finally {
                     surface.unlockCanvasAndPost(canvas);