Why is AsyncTask
here causing obstruction in code which is not related to it. For example:
Animation runs in this code:
if(!(speakMe.getStatus() == AsyncTask.Status.RUNNING) ){
((AnimationDrawable) mImageView.getBackground()).start();
Toast.makeText(getActivity(), "In the zone!", Toast.LENGTH_SHORT).show();
// speakMe = new SpeakQuote();
// speakMe.execute(quote);
}
But not in this:
if(!(speakMe.getStatus() == AsyncTask.Status.RUNNING) ){
((AnimationDrawable) mImageView.getBackground()).start();
Toast.makeText(getActivity(), "In the zone!", Toast.LENGTH_SHORT).show();
speakMe = new SpeakQuote();
speakMe.execute(quote);
}
Or in this:
if(!(speakMe.getStatus() == AsyncTask.Status.RUNNING) ){
speakMe = new SpeakQuote();
speakMe.execute(quote);
((AnimationDrawable) mImageView.getBackground()).start();
Toast.makeText(getActivity(), "In the zone!", Toast.LENGTH_SHORT).show();
}
Note that I am running this code inside onClick of an ImageView in my Fragment Class.