S
S
SerGio13132016-11-24 13:20:34
Java
SerGio1313, 2016-11-24 13:20:34

How to make a delay after executing requests?

Good afternoon.
I do two asynchronous requests (Retrofit).
The code is placed in the button click handler.
You need to wait for the two enqueue() to complete, make a delay (while the progress bar is displayed) and finally execute the method that takes the parameters changed when the two enqueue() requests are executed.
How to make a delay?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wwarlock, 2016-12-01
@wwarlock

In Java, starting from the eighth version, there is such a thing as Future and their execution queues.
If the version of android you are running supports them, then this is your most obvious decision.
In a more general case, such a queue can be organized independently.
We launched streams, each of them has an empty array (list, circular buffer, whatever) as a parameter, where they write their result.
In the loop, check your filling conditions and as soon as they satisfy you, then exit the loop.

Z
z0rgoyok, 2016-12-05
@z0rgoyok

Use RxJava and CombineLatests

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question