Why async methods call sooner in Retrofit 2?
<p>As you can see in the code below, I've call the getPostByPageId() method to get data from server and then check if the data was returned back, I do other jobs.</p>

<pre><code> private void recyclerViewJobs() {
    getPostByPageId();
    if (pageDtoList.size() &gt; 0) {
        emptyText.setVisibility(View.GONE);
        recyclerView.setVisibility(View.VISIBLE);
        PagesAdapter adapter = new PagesAdapter(pageDtoList, context);
        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
    } else {
        emptyText.setVisibility(View.VISIBLE);
        recyclerView.setVisibility(View.GONE);
    }


}
</code></pre>

<p>.....</p>

<pre><code>private void getPostByPageId() {

    IPageEndPoint pageEndPoint = ServiceGenerator.createService(IPageEndPoint.class);
    Call&lt;List&lt;PageDto&gt;&gt; call = pageEndPoint.getPostByPageId(profileId);
    call.enqueue(new retrofit2.Callback&lt;List&lt;PageDto&gt;&gt;() {
        @Override
        public void onResponse(Call&lt;List&lt;PageDto&gt;&gt; call, Response&lt;List&lt;PageDto&gt;&gt; response) {
            if (response.isSuccessful()) {
                pageDtoList = response.body();
            } else {
                log.toast("response is not successful for getPostByPageId");
            }
        }

        @Override
        public void onFailure(Call&lt;List&lt;PageDto&gt;&gt; call, Throwable t) {
            log.toast("getPostByPageId onFailure");
        }
    });
}
</code></pre>

<p>I don't know why in the recyclerViewJobs() method, the if condition work first?</p>

<blockquote>
  <p>maybe I could not explain my issue very well but my big problem is to
  know when I want to get some data from REST and then use this data to
  another REST service, how can I do this job because enqueue in
  retrofit works asynchronous and do not wait for first method, because
  of that it is beginning the second method in another thread and
  because my data was not gotten from first method yet, my program was
  crashed and I didn't get the answer. That is my problem.....</p>
</blockquote>

<p>Cheers</p>