title: Android - ArrayList size always return 0
body: <p>I am getting places with Google Maps and retrofit and adding them in a list. I want to collect all places in a list, I did it like in the below but <code>allItem</code> list size returns always 0, I can not figure out why, am I missing something?. Can anyone help me?</p>
  
  <p>My Globals</p>
  
  <pre><code>ArrayList&lt;MapData.ResultsBean&gt; myList;
  ArrayList&lt;MapData.ResultsBean&gt; allItems;
  </code></pre>
  
  <p>Button click function</p>
  
  <pre><code> menuOption1.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  myList = new ArrayList&lt;MapData.ResultsBean&gt;();
                  allItems = new ArrayList&lt;MapData.ResultsBean&gt;();
  
                  allItems.addAll(selectAllFrom("restaurant", myList));
                  allItems.addAll(selectAllFrom("cafe", myList));
                  allItems.addAll(selectAllFrom("bar", myList));
  
                  Log.v("Size", "Places List size : " + allItems.size() + "");
              }
          });
  </code></pre>
  
  <p>SelectAllFrom function</p>
  
  <pre><code>private ArrayList&lt;MapData.ResultsBean&gt; selectAllFrom(final String type, final ArrayList&lt;MapData.ResultsBean&gt; list) {
  
          // Creating an object of our api interface
          ApiService myApi = RetroClient.getApiService();
  
          // Calling JSON
          Call&lt;MapData&gt; call = myApi.getNearbyPlaces(type, mLastLocation.getLatitude() + "," + mLastLocation.getLongitude(), PROXIMITY_RADIUS);
  
          call.enqueue(new Callback&lt;MapData&gt;() {
              @Override
              public void onResponse(Call&lt;MapData&gt; call, Response&lt;MapData&gt; response) {
  
                  Log.v("Response Code", "Response Code is : " + response.code());
  
                  if (response.isSuccessful()){
  
                      try {
                          // This loop will go through all the results
                          for (int i = 0; i &lt; response.body().getResults().size(); i++) {
                              addToList(list, response.body().getResults().get(i));
                          }
  
                          Log.v(type, "List Size : " + list.size() + "");
  
                      } catch (Exception e) {
                          Log.d("onResponse", "There is an error");
                          e.printStackTrace();
                      }
  
                  } else {
                      Toast.makeText(getApplicationContext(), "Something work wrong", Toast.LENGTH_LONG).show();
                  }
  
              }
  
              @Override
              public void onFailure(Call&lt;MapData&gt; call, Throwable t) {
  
                  Toast.makeText(getApplicationContext(), "On Failure", Toast.LENGTH_LONG).show();
              }
          });
  
  
          return  list;
  
      }
  </code></pre>
  
  <p>and last, here is my addToList function</p>
  
  <pre><code>void addToList(ArrayList&lt;MapData.ResultsBean&gt; myList, MapData.ResultsBean item){
      if(!myList.contains(item))
          myList.add(item);
  }
  </code></pre>
  
  <p>This is my logcat, allItem size always return 0</p>
  
  <pre><code>V/Size: Places List size : 0
  V/restaurant: List Size : 20
  V/bar: List Size : 21
  V/cafe: List Size : 41
  </code></pre>