I need some advice. I’m building an app that has a sequence of 4 actions that will occur when the user presses a button. As soon as the user presses GO, that button must become un-enabled, and some visual cues in the interface must show which of the 4 actions is taking place. (Changing the visibility of ImageView, for example) The GUI must change immediately to keep in sync with sounds that are playing.
After each of the 4 actions, the GUI must change to reflect which of the actions is currently happening.
Current attempts – I can’t get the GUI to change before the first action starts (sound is playing), and at the appropriate times in between the actions. The actions are to play 4 different sounds. Currently, I’m using the MediaPlayer.
I haven’t had any luck trying to force the GUI to update when I want to. I have used AsyncTask, and tried all combinations of setEnabled(), invalidate(), forceLayout(), refreshDrawableState() to try to force things to happen in the gui when I want them to – corresponding to the 4 sounds playing in sequence.
My problem seems to be that I’m trying to do 4 things in one onClick handler. I have been really struggling with validate() calling reDraw at “sometime in the future.”
I don’t know what design pattern would be best suited to providing a visual cue to the 4 things that are happening in sequence.
I’m just starting to look at Handlers. Is this the way to go? I thought it would be easy. Any advice?
If I remember correctly the
onPreExecuteandonPostExecutemethods of the AsyncTask execute on the GUI thread. Doesn’t updating the GUI from these methods work?