I want to lock the ontouch listener when the animation is being played. this is my code.
public class MainActivity extends Activity implements OnTouchListener {
boolean gifIsPlaying;
long PLAYING_TIME_OF_GIF = 111;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GIFWebView view = new GIFWebView
(this, "file:///android_asset/imageedit_ball.gif");
gifIsPlaying = true;
new Handler().postDelayed(new Runnable() {
public void run() {
gifIsPlaying = false;
}
}, PLAYING_TIME_OF_GIF);
setContentView(view);
view.setOnTouchListener(this);
}
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if (gifIsPlaying) {
// No response to touch events
} else {
// Respond to touch events
GIFWebView view1 = new GIFWebView
(this, "file:///android_asset/imageedit_ball.gif");
gifIsPlaying = true;
new Handler().postDelayed(new Runnable() {
public void run() {
gifIsPlaying = false;
}
}, PLAYING_TIME_OF_GIF);
setContentView(view1);
}
// Consume touch event
return true;
}
}
I have tried to implement ontouch within ontouch but no use. I want to temperory lock ontouch till the gif animation completes a loop. Please help.