title: Exception Dispatching Input Event and Null Pointer Exception on SwipeRefreshLayout Pull down
body: <p>I have a swipe to refresh layout (part of android.support.v4 revision 19.1), and when I swipe down on the layout I can get to the point where the top part is full, but swiping down any further will cause the app to crash, and the logcat points to no specific line in my code. Since SwipeRefreshLayout is only a couple of months old, their is not a lot of information on the internet to help me figure out what the problem is. Before I was having trouble adding the support v4 revision 19.1 to my build path, but I'm pretty sure I fixed that. Here is the logcat, along with the layout file and the code for my SwipeRefreshLayout. Along with a screenshot of when the app crashes.</p>
  
  <pre><code>06-18 23:09:31.527: E/InputEventReceiver(25459): Exception dispatching input event.
  06-18 23:09:31.547: E/AndroidRuntime(25459): FATAL EXCEPTION: main
  06-18 23:09:31.547: E/AndroidRuntime(25459): Process: com.bernard.beaconportal, PID: 25459
  06-18 23:09:31.547: E/AndroidRuntime(25459): java.lang.NullPointerException
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.support.v4.widget.SwipeRefreshLayout.startRefresh(SwipeRefreshLayout.java:441)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.support.v4.widget.SwipeRefreshLayout.onTouchEvent(SwipeRefreshLayout.java:399)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.View.dispatchTouchEvent(View.java:7706)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2210)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1945)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2339)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1569)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.app.Activity.dispatchTouchEvent(Activity.java:2492)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2286)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.View.dispatchPointerEvent(View.java:7886)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3947)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3826)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3392)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3442)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3411)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3518)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3419)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3575)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3392)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3442)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3411)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3419)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3392)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5532)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5512)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5483)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5612)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5585)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:5631)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
  06-18 23:09:31.547: E/AndroidRuntime(25459):    at android.view.Choreographer.doCa
  </code></pre>
  
  <p>Here is the layout</p>
  
  <pre><code>&lt;android.support.v4.widget.SwipeRefreshLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="#ffffff"
      android:id="@+id/swipe" &gt;
  
      &lt;ListView
          android:id="@+id/listView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentTop="true"
           android:background="#ffffff"&gt;
  
      &lt;/ListView&gt;
  &lt;/android.support.v4.widget.SwipeRefreshLayout&gt;
  </code></pre>
  
  <p>here is the code that deals with SwipeRefreshLayout</p>
  
  <pre><code>SwipeRefreshLayout swipeLayout; 
  
  
      public static final String KEY_HOMEWORK="homework";
      public static final String KEY_DESC="desc";
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
  
  
           View swipe = inflater.inflate(R.layout.activity_main, container, false); 
  
           swipeLayout = (SwipeRefreshLayout) swipe.findViewById(R.id.swipe);
  
           swipeLayout.setEnabled(false);
  
      ListView lView = (ListView) swipe.findViewById(R.id.listView1);
  
      lView.setOnScrollListener(new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView absListView, int i) {
  
          }
  
          @Override
          public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                  if (firstVisibleItem == 0)
                      swipeLayout.setEnabled(true);
                  else
                      swipeLayout.setEnabled(false);
          }
      });
  
  
      return swipe;
  
      }
  </code></pre>
  
  <p>And here is a screenshot of it crashing, as you can see it has been swiped all the way down, and normally it would trigger something at this point. But then it crashes.</p>
  
  <p><img src="https://i.stack.imgur.com/BDsuP.png" alt="And here is a screenshot of it crashing, as you can see it has been swiped all the way down, and normally it would trigger something at this point. But then it crashes."></p>