@@ -1017,51 +1017,53 @@ private boolean onTouchUpScrolling(final MotionEvent event) {
10171017
10181018 private boolean onTouchUpTap (final MotionEvent event ) {
10191019 final int motionPosition = mMotionPosition ;
1020- final View child = getChildAt (motionPosition );
1021- if (child != null && !child .hasFocusable ()) {
1022- if (mTouchMode != TOUCH_MODE_DOWN ) {
1023- child .setPressed (false );
1024- }
1025-
1026- if (mPerformClick == null ) {
1027- invalidate ();
1028- mPerformClick = new PerformClick ();
1029- }
1030-
1031- final PerformClick performClick = mPerformClick ;
1032- performClick .mClickMotionPosition = motionPosition ;
1033- performClick .rememberWindowAttachCount ();
1034-
1035- // mResurrectToPosition = motionPosition;
1036-
1037- if (mTouchMode == TOUCH_MODE_DOWN || mTouchMode == TOUCH_MODE_TAP ) {
1038- final Handler handler = getHandler ();
1039- if (handler != null ) {
1040- handler .removeCallbacks (mTouchMode == TOUCH_MODE_DOWN ?
1041- mPendingCheckForTap : mPendingCheckForLongPress );
1020+ if (motionPosition >= 0 ) {
1021+ final View child = getChildAt (motionPosition );
1022+ if (child != null && !child .hasFocusable ()) {
1023+ if (mTouchMode != TOUCH_MODE_DOWN ) {
1024+ child .setPressed (false );
1025+ }
1026+
1027+ if (mPerformClick == null ) {
1028+ invalidate ();
1029+ mPerformClick = new PerformClick ();
10421030 }
1043- mLayoutMode = LAYOUT_NORMAL ;
1044- if (!mDataChanged && mAdapter .isEnabled (motionPosition )) {
1045- mTouchMode = TOUCH_MODE_TAP ;
1046- layoutChildren ();
1047- child .setPressed (true );
1048- setPressed (true );
1049- postDelayed (new Runnable () {
1050- public void run () {
1051- child .setPressed (false );
1052- setPressed (false );
1053- if (!mDataChanged ) {
1054- post (performClick );
1031+
1032+ final PerformClick performClick = mPerformClick ;
1033+ performClick .mClickMotionPosition = motionPosition ;
1034+ performClick .rememberWindowAttachCount ();
1035+
1036+ // mResurrectToPosition = motionPosition;
1037+
1038+ if (mTouchMode == TOUCH_MODE_DOWN || mTouchMode == TOUCH_MODE_TAP ) {
1039+ final Handler handler = getHandler ();
1040+ if (handler != null ) {
1041+ handler .removeCallbacks (mTouchMode == TOUCH_MODE_DOWN ?
1042+ mPendingCheckForTap : mPendingCheckForLongPress );
1043+ }
1044+ mLayoutMode = LAYOUT_NORMAL ;
1045+ if (!mDataChanged && motionPosition >= 0 && mAdapter .isEnabled (motionPosition )) {
1046+ mTouchMode = TOUCH_MODE_TAP ;
1047+ layoutChildren ();
1048+ child .setPressed (true );
1049+ setPressed (true );
1050+ postDelayed (new Runnable () {
1051+ public void run () {
1052+ child .setPressed (false );
1053+ setPressed (false );
1054+ if (!mDataChanged ) {
1055+ post (performClick );
1056+ }
1057+ mTouchMode = TOUCH_MODE_IDLE ;
10551058 }
1056- mTouchMode = TOUCH_MODE_IDLE ;
1057- }
1058- }, ViewConfiguration .getPressedStateDuration ());
1059- } else {
1060- mTouchMode = TOUCH_MODE_IDLE ;
1059+ }, ViewConfiguration .getPressedStateDuration ());
1060+ } else {
1061+ mTouchMode = TOUCH_MODE_IDLE ;
1062+ }
1063+ return true ;
1064+ } else if (!mDataChanged && motionPosition >= 0 && mAdapter .isEnabled (motionPosition )) {
1065+ post (performClick );
10611066 }
1062- return true ;
1063- } else if (!mDataChanged && mAdapter .isEnabled (motionPosition )) {
1064- post (performClick );
10651067 }
10661068 }
10671069 mTouchMode = TOUCH_MODE_IDLE ;
0 commit comments