summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-05-12 23:36:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-12 23:36:45 +0000
commit350a670e7e580ebcb14b1ef8e0dd7b53d0ca912d (patch)
tree18e4d4345ed6ffa8f81a7fca160ab70b6956ed56 /src
parent757981a0ab530d7ae7fbd83679b5aea86d02746d (diff)
parentbd180af7f0b73b0dd79a7117fb0c14370ef4d12e (diff)
Merge "Use new nested scrolling APIs"
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java1
-rw-r--r--src/com/android/dialer/widget/OverlappingPaneLayout.java39
-rw-r--r--src/com/android/dialer/widget/ViewDragHelper.java41
3 files changed, 76 insertions, 5 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index 094815182..0f3e405c3 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -252,7 +252,6 @@ public class CallLogFragment extends ListFragment
mStatusMessageView = view.findViewById(R.id.voicemail_status);
mStatusMessageText = (TextView) view.findViewById(R.id.voicemail_status_message);
mStatusMessageAction = (TextView) view.findViewById(R.id.voicemail_status_action);
-
return view;
}
diff --git a/src/com/android/dialer/widget/OverlappingPaneLayout.java b/src/com/android/dialer/widget/OverlappingPaneLayout.java
index 18920df4f..e17194e21 100644
--- a/src/com/android/dialer/widget/OverlappingPaneLayout.java
+++ b/src/com/android/dialer/widget/OverlappingPaneLayout.java
@@ -102,6 +102,11 @@ public class OverlappingPaneLayout extends ViewGroup {
*/
private boolean mIsUnableToDrag;
+ /**
+ * Tracks whether or not a child view is in the process of a nested scroll.
+ */
+ private boolean mIsInNestedScroll;
+
private float mInitialMotionX;
private float mInitialMotionY;
@@ -574,12 +579,16 @@ public class OverlappingPaneLayout extends ViewGroup {
}
if (!mCanSlide || (mIsUnableToDrag && action != MotionEvent.ACTION_DOWN)) {
- mDragHelper.cancel();
+ if (!mIsInNestedScroll) {
+ mDragHelper.cancel();
+ }
return super.onInterceptTouchEvent(ev);
}
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
- mDragHelper.cancel();
+ if (!mIsInNestedScroll) {
+ mDragHelper.cancel();
+ }
return false;
}
@@ -601,7 +610,9 @@ public class OverlappingPaneLayout extends ViewGroup {
final float ady = Math.abs(y - mInitialMotionY);
final int slop = mDragHelper.getTouchSlop();
if (ady > slop && adx > ady || !isCapturableViewUnder((int) x, (int) y)) {
- mDragHelper.cancel();
+ if (!mIsInNestedScroll) {
+ mDragHelper.cancel();
+ }
mIsUnableToDrag = true;
return false;
}
@@ -837,6 +848,27 @@ public class OverlappingPaneLayout extends ViewGroup {
mPreservedOpenState = ss.isOpen;
}
+ @Override
+ public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
+ final boolean startNestedScroll = (nestedScrollAxes & SCROLL_AXIS_VERTICAL) != 0;
+ if (startNestedScroll) {
+ mIsInNestedScroll = true;
+ mDragHelper.startNestedScroll(mSlideableView);
+ }
+ return startNestedScroll;
+ }
+
+ @Override
+ public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) {
+ mDragHelper.processNestedScroll(mSlideableView, 0, dy, consumed);
+ }
+
+ @Override
+ public void onStopNestedScroll(View child) {
+ mDragHelper.stopNestedScroll(mSlideableView);
+ mIsInNestedScroll = false;
+ }
+
private class DragHelperCallback extends ViewDragHelper.Callback {
@Override
@@ -883,7 +915,6 @@ public class OverlappingPaneLayout extends ViewGroup {
top += mSlideRange;
}
- int left;
mDragHelper.settleCapturedViewAt(releasedChild.getLeft(), top);
invalidate();
}
diff --git a/src/com/android/dialer/widget/ViewDragHelper.java b/src/com/android/dialer/widget/ViewDragHelper.java
index 748979f8c..83e870775 100644
--- a/src/com/android/dialer/widget/ViewDragHelper.java
+++ b/src/com/android/dialer/widget/ViewDragHelper.java
@@ -1447,4 +1447,45 @@ public class ViewDragHelper {
return result;
}
+
+ /**
+ * Prepares the {@link ViewDragHelper} for the beginning of a nested scroll.
+ *
+ * @param target The child view that is dispatching the nested scroll.
+ */
+ public void startNestedScroll(View target) {
+ setDragState(STATE_DRAGGING);
+ mCapturedView = target;
+ }
+
+ /**
+ * Informs the {@link ViewDragHelper} that a nested scroll has ended.
+ *
+ * @param target The child view that is dispatching the nested scroll.
+ */
+ public void stopNestedScroll(View target) {
+ dispatchViewReleased(0, 0);
+ }
+
+ /**
+ * Update the {@link ViewDragHelper} with a new nested scrolling event.
+ *
+ * @param target The child view that is dispatching the nested scroll.
+ * @param dx The x distance scrolled on the child, in pixels.
+ * @param dy The y distance scroll on the child, in pixels.
+ * @param consumed An int array for the {@link ViewDragHelper} to report back the scroll
+ * deltas that it consumed.
+ */
+ public void processNestedScroll(View target, int dx, int dy, int[] consumed) {
+ final int targetX = mCapturedView.getLeft() + dx;
+ final int targetY = mCapturedView.getTop() + dy;
+ dragTo(targetX, targetY, dx, dy);
+ if (consumed != null) {
+ final int unconsumedX = targetX - mCapturedView.getLeft();
+ final int unconsumedY = targetY - mCapturedView.getTop();
+ consumed[0] = dx - unconsumedX;
+ consumed[1] = dy - unconsumedY;
+ }
+ }
+
}