Skip to content Skip to sidebar Skip to footer

Stop / Pause An Iterator

I am trying to implement an animation of Markers on a Google Map. The issue I am running into is an Animation being started while another Animation is still happening for a specifi

Solution 1:

Just use a while loop to stop your iterator logic.

while (iterator.hasNext()) {
    // waitwhile (!someBooleanConditionToWaitFor) { }

    // do your other stuff// when you're done your other stuff, set it back to false.
    someBooleanConditionToWaitFor = false;
}

When your animation has finished, set the condition to true so that it continues. When you're at the end of that iteration, set it back to false so it waits again.

Solution 2:

Create a global static boolean flag

publicstaticboolean criteriaMet=false;

After your criteria is met set it to true. Continue the iteration of the loop only if the flag is true.

Post a Comment for "Stop / Pause An Iterator"