21 января 2012 г. 12:08 пользователь skink <[email protected]> написал:

>
> [ snip ]
> Kostya,
>
> thanks for your answer, however:
>
> i tried 3 solutions (all of them are fixing my problem btw):
>
> 1) the most brutal: create new instance of GestureDetector
>
> public boolean onDoubleTap(MotionEvent e) {
>        mDetector = new GestureDetector(this);
>        // start activity here
> }
>
> 2) cancel() GestureDetector in-place of onDoubleTap
>
> public boolean onDoubleTap(MotionEvent e) {
>        e.setAction(MotionEvent.ACTION_CANCEL);
>        mDetector.onTouchEvent(e);
>       // start activity here
> }
>
> 3) cancel() GestureDetector with posted Runnable
>
> public boolean onDoubleTap(final MotionEvent e) {
>        mHandler.post(new Runnable() {
>                public void run() {
>                        e.setAction(MotionEvent.ACTION_CANCEL);
>                        mDetector.onTouchEvent(e);
>                }
>        });
>       // start activity here
> }
>
> but i'm still in doubts: i think that my original solution using
> onDoubleTapEvent is the most elegant and it doesn't use some internal
> "black magic" knowledge about cancel() and MotionEvent.ACTION_CANCEL
>
>
ACTION_CANCEL isn't anything secret:

http://developer.android.com/reference/android/view/MotionEvent.html

Under "consistency guarantees", it says:

"Views should always be prepared to handle
ACTION_CANCEL<http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_CANCEL>
"

I suppose that applies to GestureDetector as well.

On the other hand, at this point, you've got four solutions and expressed
strong liking for one of them (your original one) - sounds like a plan then
:)

-- Kostya


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

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

Reply via email to