title: Exception dispatching input event. and LruCache
body: <p>I have a problem when I scroll my <code>ListView</code>. After a while I get the errors in logcat, but I dodn't know what the problem is.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class ListFeedAdapter extends BaseAdapter {
  
      private ArrayList&lt;Feed&gt; feeds;
      private LruCache&lt;String, Bitmap&gt; mMemoryCache;
  
      private LayoutInflater inflater;
  
      public ListFeedAdapter(Context context,ArrayList&lt;Feed&gt; feeds) {
          inflater = LayoutInflater.from(context);
          this.feeds = feeds;
           // Bitmap Cache
          final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
          final int cacheSize = maxMemory / 8;
          mMemoryCache = new LruCache&lt;String, Bitmap&gt;(cacheSize) {
              @Override
              protected int sizeOf(String key, Bitmap bitmap) {
                  return bitmap.getByteCount() / 1024;
              }
  
          };
  
      }
  
  
      public int getCount() {
          return feeds.size();
      }
  
  
       // Permet de retourner un objet contenu dans la liste
  
  
      public Object getItem(int index) {
          return feeds.get(index);
      }
  
  
      public long getItemId(int index) {
          return this.feeds.get(index).getId();
  
      }
  
  
  
       // * Voici la partie la plus complexe de la classe
  
  
  
  
      public View getView(int position, View convertView, ViewGroup parent){
  
          FeedView fv=null;
  
      if (convertView == null) {
              fv = new FeedView();
  
              convertView = inflater.inflate(R.layout.feed_view, null);
               fv.image=(ImageView)convertView.findViewById(R.id.imageview);
              fv.description = (TextView)convertView.findViewById(R.id.description);            
              fv.title = (TextView)convertView.findViewById(R.id.title);
              fv.pubDate = (TextView)convertView.findViewById(R.id.pub_date);
              convertView.setTag(fv);
  
          } else {
              fv = (FeedView) convertView.getTag();
          }    
  
       Bitmap bitmap = mMemoryCache.get(feeds.get(position).getImage());
  
       if (bitmap != null) {
           fv.image.setImageBitmap(bitmap);
       } else {
  
           ThumbnailTask getbitmap=new ThumbnailTask(fv.image, feeds.get(position).getImage(), position);
           getbitmap.execute();
  
  
       }
  
  
  
          fv.description.setText(feeds.get(position).getDescription());
          fv.pubDate.setText(feeds.get(position).getPubDate());
          fv.title.setText(feeds.get(position).getTitle());
  
          return convertView;
      }
  
  
  
  
      public static int getSizeInBytes(Bitmap bitmap) {
          if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
              return bitmap.getByteCount();
          } else {
              return bitmap.getRowBytes() * bitmap.getHeight();
          }
      }
  
  
  
      public class ThumbnailTask extends AsyncTask&lt;Void,Void,Bitmap&gt; {
  
  
           private  ImageView bmImage;
           private String url;
           private int pst;
  
           public ThumbnailTask(ImageView image,String url,int pst) {
                  this.bmImage=image; 
                  this.url=url;
                  this.pst=pst;
                  bmImage.setTag(pst);
                  bmImage.setImageBitmap(null);
            }
  
  
  
          @Override
          protected Bitmap doInBackground(Void... arg0) {
  
  
  
               URL url=null;
               HttpURLConnection connection;
               InputStream input;
              Bitmap img=null;
  
                  try {
                        url = new URL(this.url);
                      connection = (HttpURLConnection) url.openConnection();
                      connection.connect();
                       input = connection.getInputStream();
                     img = BitmapFactory.decodeStream(input);
                      input.close();
  
                  } catch (IOException e) {
                      Log.e("img", "Error getting bitmap"); 
                  }           
                  mMemoryCache.put(this.url, img);
  
              return img;
          }
  
          protected void onPostExecute(Bitmap bitmap) {
               super.onPostExecute(bitmap);
               if(bitmap != null &amp;&amp; ((Integer)this.bmImage.getTag()) == this.pst)
                           this.bmImage.setImageBitmap(bitmap);
              }    
  }
  </code></pre>
  
  <p>And this is the LogCat data:</p>
  
  <pre class="lang-none prettyprint-override"><code>09-06 21:29:17.139: E/InputEventReceiver(2216): Exception dispatching input event.
  09-06 21:29:17.209: D/AndroidRuntime(2216): Shutting down VM
  09-06 21:29:17.259: W/dalvikvm(2216): threadid=1: thread exiting with uncaught exception (group=0xb2a9fba8)
  09-06 21:29:17.449: E/AndroidRuntime(2216): FATAL EXCEPTION: main
  09-06 21:29:17.449: E/AndroidRuntime(2216): Process: com.test.fragmenttest, PID: 2216
  09-06 21:29:17.449: E/AndroidRuntime(2216): java.lang.NullPointerException: key == null
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.util.LruCache.get(LruCache.java:113)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at com.test.fragmenttest.ListFeedAdapter.getView(ListFeedAdapter.java:113)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.widget.AbsListView.obtainView(AbsListView.java:2240)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.widget.ListView.makeAndAddView(ListView.java:1790)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.widget.ListView.fillDown(ListView.java:691)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.widget.ListView.fillGap(ListView.java:655)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5136)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3236)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.widget.AbsListView.onTouchMove(AbsListView.java:3580)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.widget.AbsListView.onTouchEvent(AbsListView.java:3424)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.View.dispatchTouchEvent(View.java:7706)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1945)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  09-06 21:29:17.449: E/AndroidRuntime(2216):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  ......
  </code></pre>