summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alan Viverette <alanv@google.com> 2015-01-26 19:35:44 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2015-01-26 19:35:44 +0000
commitd5f35c20226740e6fe6397aaf7caf6dacd5e635f (patch)
tree4490a5acdc54af617add59d47d2f6a2e39a55b28
parent361d45e67ae43996b5593b46c29f03aa648a0a6e (diff)
parenta6b9390949c4aa6f7de09fd0f44bb35ed7aabbc7 (diff)
am a6b93909: am e1eff7aa: am de8d2840: Merge "Prevent drag-to-open from cycling pressed state, propagate hotspot" into lmp-mr1-dev
* commit 'a6b9390949c4aa6f7de09fd0f44bb35ed7aabbc7': Prevent drag-to-open from cycling pressed state, propagate hotspot
-rw-r--r--core/java/android/widget/ListPopupWindow.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java
index fe8b08bea78b..d85bbb9e1571 100644
--- a/core/java/android/widget/ListPopupWindow.java
+++ b/core/java/android/widget/ListPopupWindow.java
@@ -1648,19 +1648,32 @@ public class ListPopupWindow {
private void setPressedItem(View child, int position, float x, float y) {
mDrawsInPressedState = true;
- // Ordering is essential. First update the pressed state and layout
- // the children. This will ensure the selector actually gets drawn.
- setPressed(true);
- layoutChildren();
+ // Ordering is essential. First, update the container's pressed state.
+ drawableHotspotChanged(x, y);
+ if (!isPressed()) {
+ setPressed(true);
+ }
+
+ // Next, run layout if we need to stabilize child positions.
+ if (mDataChanged) {
+ layoutChildren();
+ }
// Manage the pressed view based on motion position. This allows us to
// play nicely with actual touch and scroll events.
final View motionView = getChildAt(mMotionPosition - mFirstPosition);
- if (motionView != null) {
+ if (motionView != null && motionView != child && motionView.isPressed()) {
motionView.setPressed(false);
}
mMotionPosition = position;
- child.setPressed(true);
+
+ // Offset for child coordinates.
+ final float childX = x - child.getLeft();
+ final float childY = y - child.getTop();
+ child.drawableHotspotChanged(childX, childY);
+ if (!child.isPressed()) {
+ child.setPressed(true);
+ }
// Ensure that keyboard focus starts from the last touched position.
setSelectedPositionInt(position);