Hi there.  Have a custom gesture class that detects 'buildup' gestures
for a drawing program.  In the class, I test the current MotionEvent
and in ACTION_MOVE, set a private field mCurEvent to the current
event, process it and then set a private mPrevEvent to the same event
so that on the next ACTION_MOVE, I can compare the current and
previous events to determine distance moved, etc.  Example:

switch (ev.getAction()) {

case MotionEvent.ACTION_MOVE:
mCurEvent = MotionEvent.obtainNoHistory(ev);
if (mPrevEvent != null) {
   compare the two events
}
mPrevEvent = MotionEvent.obtainNoHistory(ev);
break;

Everything works fine, until I start trying to clean up the code
and .recycle() MotionEvents on ACTION_UP, ACTION_CANCEL.  Recycling
the current and previous event frees up resources, but on the next
touchdown and move, mCurEvent and mPrevEvent are being allocated to
the exact same object address space, meaning that setting mCurEvent =
MotionEvent.obtainNoHistory(ev); is also setting the mPrevEvent
variable that shares that points to the same object...

I'd like to recycle the events as there could be MANY created with
lots of ACTION_MOVE events...  but doing so seems to have these
results.

Any strategies or recommendations?

Thanks,

Paul

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to