I am trying to run some methods when a button is clicked and then move to next activity something like this:
Clicked Ok button -> func1() -> func2() -> funky() -> move to next activity
i can't seem to understand what should i do to make this pattern work?
Note: func1 , func2 , funky are asynchronous
I've tried EventBus pattern , but that pattern require 1 extra class to be made of each event
i know this simple task can't be that expensive
Button click - This is asynchronous (in a way; the code inside
onClick
isn't called until the button clicks). What do you do here? You wait until the button is pressed, and then execute the taskfunc1()
.func1()
- Same idea. Implement a callback for when the task is completed, then executefunc2()
Rinse, repeat.
Psuedocode:
Obviously, this can be refactored to remove the nesting, which is where the EventBus library is nice.