title: Retrofit2: wait for response before executing next task in recyclerview
body: <p>I am using recyclerview to display list of items(image and text), i am fetching the items displayed in the recyclerview list from backend, i am using retrofit2 for making rest calls and i am able to get the list from the rest and recyclerview is rendered perfectly fine.</p>
  
  <p>while displaying the list of items in the recyclerview i want to add a bitmap image to the image present in the item. Before adding this bitmap image to the image present in the item, i have to make a second retrofit call(async) to checking whether bitmap image is need for that item, if the response is true then only i have to add the bitmap image.</p>
  
  <p>Now the issue is, as i am making asynchronous call(using enqueue method) in retrofit, the recycler view is not waiting for the response from retrofit because of which am not able to draw the bitmap on the image present in the each item.</p>
  
  <p>I know we can use synchronous call fix the issue but i dont want to compromise on the performance.</p>
  
  <p>Below are the code snippets for reference.</p>
  
  <p>I am call retrofit method from the recyclerview adapter which will return boolean based on the returned value i want to draw the bitmap on the item image</p>
  
  <p>Retrofit method:</p>
  
  <pre><code>HttpRestServiceConsumer.getBaseApiInterface(false)
      .getTestWithURL(imageURL)
      .enqueue(new Callback&lt;TestResponse&gt;() {
  
          @Override
          public void onResponse(Call&lt;TestResponse&gt; call, Response&lt;TestResponse&gt; response) {
  
              try {
                  if (response.isSuccessful()) {
  
                      data = response.body().getTrackElements();
  
                      if (response.body().getTrackElements().size() &gt; 0) 
  
                            testExist = true;
  
                     else 
  
                      testExist=false;
  
  
              } catch (Exception e) {
  
              }
  
          }
  
          @Override
          public void onFailure(Call&lt;TestResponse&gt; call, Throwable t) {
  
          }
  </code></pre>