title: Android: ArrayAdapter out of bounds crash on getView after refresh
body: <p>I'm currently having a crashing issue with scrolling down a listview and pressing refresh quickly. Eclipse is giving me</p>
  
  <pre><code>11-25 23:58:51.511: E/AndroidRuntime(29736): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
  </code></pre>
  
  <p>on this code:</p>
  
  <pre><code>            mAdapter = new ArrayAdapter&lt;Link&gt;(getActivity(), R.layout.link_item,
              mLinkManager.getLinks()) {
          @Override
          public int getCount() {
              return mLinkManager.getLinks().size();
          }
  
          public long getItemId(int position) {
              return mLinkManager.getLinks().get(position).getId().hashCode();
          }
  
          public Link getItem(int position) {
              return mLinkManager.getLinks().get(position);
          }
  
          public View getView(int position, View convertView, ViewGroup parent) {
              if (convertView == null) {
                  convertView = getActivity().getLayoutInflater().inflate(
                          R.layout.link_item, null);
              }
  
              Link link = mLinkManager.getLinks().get(position);
  
              // Set textview stuff from links here
  
              return convertView;
          };
      };
  
      setListAdapter(mAdapter);
  }
  </code></pre>
  
  <p>The crash occurs on the last line. Is there a way to stop getView() method once I press refresh? Any help would be greatly appreciated.</p>
  
  <pre><code>private class RefreshLinksTask extends AsyncTask&lt;Void, Void, Void&gt; {
      @Override
      protected void onPreExecute() {
          Log.d(TAG, "Refreshing...");
          if (mIsRefreshing || mIsDownloading)
              cancel(true);
          mIsRefreshing = true;
          super.onPreExecute();
      }
  
      @Override
      protected Void doInBackground(Void... params) {
          mLinkManager.refreshLinks();
          return null;
      }
  
      @Override
      protected void onPostExecute(Void result) {
          if (mAdapter != null) {
              mAdapter.notifyDataSetChanged();
          } 
          else {
              createAdapter();
          }
          mIsRefreshing = false;
          super.onPostExecute(result);
      }
  }
  </code></pre>