### Question:
ListViewCompat { public static boolean canScrollList(@NonNull ListView listView, int direction) { if (Build.VERSION.SDK_INT >= 19) { return listView.canScrollList(direction); } else { final int childCount = listView.getChildCount(); if (childCount == 0) { return false; } final int firstPosition = listView.getFirstVisiblePosition(); if (direction > 0) { final int lastBottom = listView.getChildAt(childCount - 1).getBottom(); final int lastPosition = firstPosition + childCount; return lastPosition < listView.getCount() || (lastBottom > listView.getHeight() - listView.getListPaddingBottom()); } else { final int firstTop = listView.getChildAt(0).getTop(); return firstPosition > 0 || firstTop < listView.getListPaddingTop(); } } } private  ListViewCompat(); static void scrollListBy(@NonNull ListView listView, int y); static boolean canScrollList(@NonNull ListView listView, int direction);  }### Answer:
@Test public void testCanScroll() throws Throwable { final int itemCount = mListView.getAdapter().getCount(); assertEquals(0, mListView.getFirstVisiblePosition()); assertFalse(ListViewCompat.canScrollList(mListView, -1)); assertTrue(ListViewCompat.canScrollList(mListView, 1)); runOnMainAndLayoutSync(mActivityTestRule, mListView, new Runnable() { @Override public void run() { mListView.setStackFromBottom(true); } }, false); assertEquals(itemCount - 1, mListView.getLastVisiblePosition()); assertFalse(ListViewCompat.canScrollList(mListView, 1)); assertTrue(ListViewCompat.canScrollList(mListView, -1)); }