title: Finish activity when a response is returned from the server, but wait for animation to end
body: <p>I send a request to server via Volley; And after send, increase a variable that show number of requests.</p>
  
  <pre><code>VolleyGeneral.getInstance().addToRequestQueue(jsonObj,TAG);
  numberOfReq++;
  </code></pre>
  
  <p>Then when I get the response, decrease that variable.</p>
  
  <pre><code>@Override
  public void onResponse(JSONObject response){
      numberOfReq--;
  }
  </code></pre>
  
  <p>On another side, i'm showing an image, using fade in animation for 2 seconds then I finish the activity and go to the next activity. </p>
  
  <p>But i want to wait for all the server responses before finishing the activity. So i write this part like it:</p>
  
  <pre><code>@Override
  public void onAnimationEnd(Animation anim){
      while(numberOfReq == 0){
          numberOfReq = -1;
          startActivity(intent);
          finish();
          break;
      }
  }
  </code></pre>
  
  <p>If server send the responses before 2 second, everything is Okey.</p>
  
  <p><strong>But</strong> if response is received after 2 second, the activity doesn't finish.</p>