title: Detecting scroll position inside a ListView (or ScrollView)
body: <p>I'm building a chat room application where new events are being polled for every X seconds.  Every time that happens, this code updates the RoomAdapter (a custom subclass of ArrayAdapter)  with the new data and scrolls it to the bottom:</p>
  
  <pre><code>RoomAdapter adapter = (RoomAdapter) getListAdapter();
  for (int i=0; i&lt;newEvents.size(); i++)
   adapter.add(newEvents.get(i));
  getListView().setSelection(events.size()-1);
  </code></pre>
  
  <p>This is fine, except that if the user is scrolling up to glance at the room's history, it's going to jump her down to the bottom when the poll happens.  What I'd like to do is have it so that if the user is already at the bottom of the list, it stays there after a poll for new events. If the user's intentionally scrolled upwards, I'd like the user not to be disturbed.</p>
  
  <p>How do I detect when I'm already scrolled to the bottom of a ListView?</p>
  
  <p>Note: I can't do getListView().getSelectedItemPosition(), because <a href="http://developer.android.com/reference/android/widget/ListView.html#setSelection%28int%29" rel="nofollow noreferrer">as the docs note</a>, calling setSelection when in touch mode does not actually select the item, just scrolls to it.</p>