From c02c7af0ec88ec56089a11138d5fcfafcf891c58 Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Wed, 20 Oct 2010 18:55:13 -0700 Subject: [PATCH] Fix obtain() when the pool is still empty Fixes bug 3116798 Change-Id: I187e79892cd2b60173ef4ebef5d2eab56eb5eb42 --- core/java/android/view/DragEvent.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core/java/android/view/DragEvent.java b/core/java/android/view/DragEvent.java index 93598cd2b703d..ebf850524b353 100644 --- a/core/java/android/view/DragEvent.java +++ b/core/java/android/view/DragEvent.java @@ -53,6 +53,14 @@ public class DragEvent implements Parcelable { private DragEvent() { } + private void init(int action, float x, float y, ClipDescription description, ClipData data) { + mAction = action; + mX = x; + mY = y; + mClipDescription = description; + mClipData = data; + } + static DragEvent obtain() { return DragEvent.obtain(0, 0f, 0f, null, null); } @@ -62,7 +70,9 @@ public class DragEvent implements Parcelable { final DragEvent ev; synchronized (gRecyclerLock) { if (gRecyclerTop == null) { - return new DragEvent(); + ev = new DragEvent(); + ev.init(action, x, y, description, data); + return ev; } ev = gRecyclerTop; gRecyclerTop = ev.mNext; @@ -72,11 +82,7 @@ public class DragEvent implements Parcelable { ev.mRecycled = false; ev.mNext = null; - ev.mAction = action; - ev.mX = x; - ev.mY = y; - ev.mClipDescription = description; - ev.mClipData = data; + ev.init(action, x, y, description, data); return ev; }