summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java b/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java
index f5e20510..de76a1d2 100644
--- a/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java
+++ b/java/src/com/android/intentresolver/widget/ResolverDrawerLayout.java
@@ -841,7 +841,14 @@ public class ResolverDrawerLayout extends ViewGroup {
@Override
public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed) {
- if (!consumed && Math.abs(velocityY) > mMinFlingVelocity) {
+ // TODO: find a more suitable way to fix it.
+ // RecyclerView started reporting `consumed` as true whenever a scrolling is enabled,
+ // previously the value was based whether the fling can be performed in given direction
+ // i.e. whether it is at the top or at the bottom. isRecyclerViewAtTheTop method is a
+ // workaround that restores the legacy functionality.
+ boolean shouldConsume = (Math.abs(velocityY) > mMinFlingVelocity)
+ && (!consumed || (velocityY < 0 && isRecyclerViewAtTheTop(target)));
+ if (shouldConsume) {
if (getShowAtTop()) {
if (isDismissable() && velocityY > 0) {
abortAnimation();
@@ -863,6 +870,21 @@ public class ResolverDrawerLayout extends ViewGroup {
return false;
}
+ private static boolean isRecyclerViewAtTheTop(View target) {
+ // TODO: there's a very similar functionality in #isNestedRecyclerChildScrolled(),
+ // consolidate the two.
+ if (!(target instanceof RecyclerView)) {
+ return false;
+ }
+ RecyclerView recyclerView = (RecyclerView) target;
+ if (recyclerView.getChildCount() == 0) {
+ return true;
+ }
+ View firstChild = recyclerView.getChildAt(0);
+ return recyclerView.getChildAdapterPosition(firstChild) == 0
+ && firstChild.getTop() >= recyclerView.getPaddingTop();
+ }
+
private boolean performAccessibilityActionCommon(int action) {
switch (action) {
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: