Fixes to touch handling in all apps pull up work

b/28917826
- Fast scroll bar works even when it's at the top of the recycler view
- Pull down only happens ONLY IF the thumb of the scroll bar is at top
- When container is touched during sliding down animation,
translation should not jump

Change-Id: Ic1d9a4aa77332cc0a7582556f893053003224dd3
This commit is contained in:
Hyunyoung Song
2016-06-10 12:00:02 -07:00
parent a92e0dfa0c
commit f4cbb1428a
4 changed files with 58 additions and 34 deletions

View File

@@ -257,9 +257,24 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
mAppsRecyclerView.scrollToTop();
}
public boolean isScrollAtTop() {
return ((LinearLayoutManager) mAppsRecyclerView.getLayoutManager())
.findFirstVisibleItemPosition() == 1;
/**
* Returns whether the view itself will handle the touch event or not.
*/
public boolean shouldContainerScroll(float x, float y) {
int[] point = new int[2];
point[0] = (int) x;
point[1] = (int) y;
Utilities.mapCoordInSelfToDescendent(mAppsRecyclerView, this, point);
// if the MotionEvent is inside the thumb, container should not be pulled down.
if (mAppsRecyclerView.getScrollBar().isNearThumb(point[0], point[1])){
return false;
}
// If scroller is at the very top, then it's okay for the container to be pulled down.
if (Float.compare(0f, mAppsRecyclerView.getScrollBar().getThumbOffset().y) == 0) {
return true;
}
return false;
}
/**
* Focuses the search field and begins an app search.