title: AsyncTask Arraylist.clear() not working
body: <p>I am unable to clear the data from array.</p>
  
  <p>on first run it has 10 elements
  on second run it has +10 elements, Total 20.</p>
  
  <p>I tried .clear() method,  notifyDataSetChanged() but they are not working.</p>
  
  <pre><code>public void getCast() {
      new AsyncTask&lt;Void, Void, Void&gt;() {
  
          ArrayList&lt;CastClass&gt; castList = new ArrayList&lt;&gt;();
  
          @Override
          protected Void doInBackground(Void... voids) {
  
              if (castList != null) {
                  castList.clear();
              }
  
              API api = new API();
              URL url = api.createCastUrl(getData.getMovieId());
  
              //RequestUrl
              try {
                  String jsonResponse = NetworkUtils.getConnection(url);
  
                  castList = CastJson.getMovieCastListFromJson(jsonResponse);
  
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return null;
          }
  
          @Override
          protected void onPostExecute(Void aVoid) {
              mCastAdapter.setMoviesCastDataData(castList);
              mCastAdapter.notifyDataSetChanged();
              Log.d(TAG, "onPostExecute: CASTLIST INPUT" + castList.size());
          }
      }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
  }
  04-12 16:27:58.626 1874-1960/vimalroxy.popularmoviesroxy D/API: Built URI Cast = http://api.themoviedb.org/3/movie/295693/credits?api_key=xxxxx
  04-12 16:27:59.131 1874-1874/vimalroxy.popularmoviesroxy D/CastAdapter: setMoviesCastDataData: CAST LIST9
  04-12 16:27:59.131 1874-1874/vimalroxy.popularmoviesroxy D/DetailActivity: onPostExecute: CASTLIST INPUT9
  04-12 16:28:00.746 1874-1878/vimalroxy.popularmoviesroxy I/art: Do partial code cache collection, code=29KB, data=30KB
  04-12 16:28:00.747 1874-1878/vimalroxy.popularmoviesroxy I/art: After code cache collection, code=29KB, data=30KB
  04-12 16:28:00.747 1874-1878/vimalroxy.popularmoviesroxy I/art: Increasing code cache capacity to 128KB
  04-12 16:28:05.879 1874-1959/vimalroxy.popularmoviesroxy D/API: Built URI Cast = http://api.themoviedb.org/3/movie/321612/credits?api_key=xxxxx
  04-12 16:28:05.879 1874-1878/vimalroxy.popularmoviesroxy I/art: Do partial code cache collection, code=58KB, data=62KB
  04-12 16:28:05.884 1874-1878/vimalroxy.popularmoviesroxy I/art: After code cache collection, code=57KB, data=62KB
  04-12 16:28:05.884 1874-1878/vimalroxy.popularmoviesroxy I/art: Increasing code cache capacity to 256KB
  04-12 16:28:06.455 1874-1874/vimalroxy.popularmoviesroxy D/CastAdapter: setMoviesCastDataData: CAST LIST19
  04-12 16:28:06.455 1874-1874/vimalroxy.popularmoviesroxy D/DetailActivity: onPostExecute: CASTLIST INPUT19
  </code></pre>
  
  <p><strong>ADAPTER :</strong></p>
  
  <pre><code>public class CastAdapter extends RecyclerView.Adapter&lt;CastAdapter.CastViewHolder&gt; {
  
      private static final String TAG = "CastAdapter";
  
      private Context mContext;
      private ArrayList&lt;CastClass&gt; mMoviesCastData;
  
      public CastAdapter(Context context) {
          mContext = context;
      }
  
      @Override
      public CastViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  
          View view = LayoutInflater.from(mContext).inflate(R.layout.cast_item_view, null, false);
          return new CastViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(final CastViewHolder holder, int position) {
  
          String name = mMoviesCastData.get(position).getCastName();
  
          String imageLink = mMoviesCastData.get(position).getCastImage();
          Uri uri = Uri.parse("https://image.tmdb.org/t/p/w150/" + imageLink);
  
          holder.cast_name.setText(name);
  
          Glide.with(mContext)
                  .load(uri)
                  .asBitmap()
                  .diskCacheStrategy(DiskCacheStrategy.ALL)
                  .centerCrop()
                  .placeholder(R.drawable.person_icon)
                  .into(new BitmapImageViewTarget(holder.cast_image) {
                      @Override
                      protected void setResource(Bitmap resource) {
                          RoundedBitmapDrawable circularBitmapDrawable =
                                  RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
                          circularBitmapDrawable.setCircular(true);
                          holder.cast_image.setImageDrawable(circularBitmapDrawable);
                      }
                  });
      }
  
      @Override
      public int getItemCount() {
          if (mMoviesCastData == null) return 0;
          return mMoviesCastData.size();
      }
  
      class CastViewHolder extends RecyclerView.ViewHolder {
          TextView cast_name;
          ImageView cast_image;
  
          public CastViewHolder(View itemView) {
              super(itemView);
              cast_name = (TextView) itemView.findViewById(R.id.cast_item_name);
              cast_image = (ImageView) itemView.findViewById(R.id.cast_item_picture);
          }
  }
  
  public void setMoviesCastDataData(ArrayList&lt;CastClass&gt; moviesCastData) {
      if (mMoviesCastData != null) {
          mMoviesCastData.clear();
          mMoviesCastData = moviesCastData;
      } else {
          mMoviesCastData = moviesCastData;
      }
      notifyDataSetChanged();
      Log.d(TAG, "setMoviesCastDataData: CAST LIST" + moviesCastData.size());
  }
  </code></pre>
  
  <p>}</p>