0

I have a custom view that does some custom drawing when touched, and I'd like to fire the click event after drawing has finished.

I tried overriding the onTouchEvent to start the animation and call performClick() when drawing has finished, but I'm losing the click event here....

has anybody been able to get this done?

in my ontouch I start the drawing process with the drawFantastic

@Override
public boolean onTouchEvent(MotionEvent event) {

    touch_x = event.getX();
    touch_y = event.getY();
    fantasticRadius = 0;
    fantasticRadius2 = 0;
    drawFantastic();

    return super.onTouchEvent(event);
}

and this is how I draw the view and want to call the performClick after it's been drawn

private void drawFantastic() {
    final Runnable fantasticRunnable = new Runnable() {
        @Override
        public void run() {
            fantasticRadius+=15;

            // 2nd radius :)
            if(fantasticRadius>35)
                fantasticRadius2+=15;

            invalidate();

            if(!isFantastic()){
                fantasticHandler.postDelayed(this, 15);
            } else {
                animationFinished = true;
                performClick();
            }
        }
    };

    fantasticHandler.post(fantasticRunnable);
}

and here is how I try to interscept the click event

@Override
public boolean performClick() {
    if(animationFinished == true) {
        return super.performClick();
    }else {
        return false;
    }
}

I added some logging and basically looks like super.performClick(); isn't doing what I think it should be doing....

Mars
  • 4,197
  • 11
  • 39
  • 63

1 Answers1

0

Try to intercept TouchEvents :

@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
    return true;
}

@Override
public boolean onTouchEvent(MotionEvent event)
{
    // your stuff
    return super.onTouchEvent(event);
}

Hope this helps.

Florian Mac Langlade
  • 1,863
  • 7
  • 28
  • 57
  • I updated my question with some code, I'm allready using onTouchEvent but I'm only getting the Down event and performClick is not doing what it's supposed to do – Mars May 27 '14 at 14:16