title: Empty ArrayList on clicking on BottomSheet RecyclerView
body: <p>I have a MapsActivity with HeatMap on it. Like Google Maps there is an option to filter data by various categories (like Satellite, Terrain etc in case of Google Maps).</p>
  
  <p>I have a button which brings a modal bottom sheet. This bottom sheet contains a recycler view with a list of categories. </p>
  
  <p>When I click on a category and run a method to make an ArrayList of new filtered data the size turns out to be 0.</p>
  
  <p>Method in MapsActivity class</p>
  
  <pre><code>public void changeHeatMap(int category, int remove){
      int count = 0;
      if (remove==0) {
          ArrayList&lt;LatLng&gt; catHeatMap = new ArrayList&lt;&gt;(3);
          while (count &lt; il_cat_data.size()) {
              if (il_cat_data.get(count) == category) {
                  catHeatMap.add(list.get(count));
              }
              count++;
          }
          mProvider.setData(catHeatMap);
      }else{
          mProvider.setData(list);
      }
  }
  </code></pre>
  
  <p>OnClick method in the RecyclerView Adapter class</p>
  
  <pre><code>public void onClick(View view) {
          int position = getAdapterPosition();
          MapsActivity mapsActivity = new MapsActivity();
          if (position==MapsActivity.isClicked){
              MapsActivity.isClicked = -1;
              mapsActivity.changeHeatMap(position,1);
          }else{
              MapsActivity.isClicked = position;
              mapsActivity.changeHeatMap(position,0);
          }
      }
  </code></pre>
  
  <p>It throws this error </p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.maps.android.heatmaps.HeatmapTileProvider.setData(java.util.Collection)' on a null object reference
  </code></pre>
  
  <p>While loop is not executed at all in changeHeatMap method and if I put a breakpoint and check size of il_cat_data then it comes out to be 0. </p>
  
  <p>I have checked that data is added in il_cat_data when the app is started. The 'list' is an arraylist which contains complete data and is used to set up the first heatmap.</p>
  
  <p>What can be wrong here? Is data not accessible because of the modal bottom sheet.</p>