Disable ontouch listener while the gif animation is playing

Meghs

I want to disable on touch listener when the animation is being played. I have used WebView for this and the animation is running successfully. But the problem is until and unless 1 loop is completed I don't want to enable the touch listener. After a loop is completed I want to enable the touch listener so that the loop will be played again. I am using on touch motion event but unable to do what i need.

GIFWebView view = new GIFWebView(this, "file:///android_asset/imageedit_ball.gif");
setContentView(view);

public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub 
   if (event.getAction()==MotionEvent.ACTION_DOWN) { 
       // view.loadUrl("file:///android_asset/imageedit_ball.gif"); 
       GIFView view1 = new GIFView (this, "file:///android_asset/imageedit_ball.gif");
       setContentView(view1); 
       view1.setOnTouchListener(this);
   }
   return true; 
}
SilentKiller

you just need to keep a flag variable whether animation is on or it is stopped.

public boolean isAnimationOn = false;

make this variable true when animation starts and false at animation finish.

public boolean onTouch(View v, MotionEvent event){
    if (isAnimationOn)
        return false;
    else
        return true;
} 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related