diff options
| author | 2010-10-12 12:58:43 -0700 | |
|---|---|---|
| committer | 2010-10-12 12:58:43 -0700 | |
| commit | 91e9bb3b468f0d5efccdb245d151cbcda1583386 (patch) | |
| tree | 78de1a7037f709c09db92f712eb007eb1b76febe | |
| parent | be27cc6943ead560c0b404b7755b88cda0fd1eea (diff) | |
Elide undelivered drag-location messages
The recipient app could be receiving drag location updates faster than
it handled them, leading to progressive poor responsiveness. Now we
discard any undelivered pending location updates and replace them with
the newest data point when the location is updated.
Change-Id: I7299d205a0ef8ef8f5f32fd14e9ef87383d92717
| -rw-r--r-- | core/java/android/view/ViewRoot.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index 14a049c8b68a..9993c10aa002 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -1692,6 +1692,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn public final static int CHECK_FOCUS = 1013; public final static int CLOSE_SYSTEM_DIALOGS = 1014; public final static int DISPATCH_DRAG_EVENT = 1015; + public final static int DISPATCH_DRAG_LOCATION_EVENT = 1016; @Override public void handleMessage(Message msg) { @@ -1867,7 +1868,8 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn mView.onCloseSystemDialogs((String)msg.obj); } } break; - case DISPATCH_DRAG_EVENT: { + case DISPATCH_DRAG_EVENT: + case DISPATCH_DRAG_LOCATION_EVENT: { handleDragEvent((DragEvent)msg.obj); } break; } @@ -2841,7 +2843,14 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn } public void dispatchDragEvent(DragEvent event) { - Message msg = obtainMessage(DISPATCH_DRAG_EVENT, event); + final int what; + if (event.getAction() == DragEvent.ACTION_DRAG_LOCATION) { + what = DISPATCH_DRAG_LOCATION_EVENT; + removeMessages(what); + } else { + what = DISPATCH_DRAG_EVENT; + } + Message msg = obtainMessage(what, event); sendMessage(msg); } |