From 5a1db1cd6a8addc0401529454bde6e1d15f215a0 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Fri, 16 Aug 2013 15:54:17 -0700 Subject: Prevent multiple swipes at one time Bug: 10257340 Change-Id: I550ce45b30ba036e6479ad5f8b5126a69b29c167 --- .../android/dialer/list/PhoneFavoritesTileAdapter.java | 15 +++++++++++++-- src/com/android/dialer/list/SwipeHelper.java | 2 ++ src/com/android/dialer/list/SwipeableListView.java | 6 +++--- 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java index c7c8ae83c..88520dd24 100644 --- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java @@ -89,6 +89,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements /** Position of the contact pending removal. */ private int mPotentialRemoveEntryIndex = -1; + private boolean mAwaitingRemove = false; + private ContactPhotoManager mPhotoManager; protected int mNumFrequents; protected int mNumStarred; @@ -305,6 +307,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements mContactEntries.add(contact); } + mAwaitingRemove = false; + arrangeContactsByPinnedPosition(mContactEntries); notifyDataSetChanged(); @@ -636,6 +640,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements unstarAndUnpinContact(entry.lookupKey); notifyDataSetChanged(); removed = true; + mAwaitingRemove = true; } cleanTempVariables(); return removed; @@ -1000,7 +1005,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements @Override public boolean onInterceptTouchEvent(MotionEvent ev) { - if (mSwipeHelper != null) { + if (mSwipeHelper != null && isSwipeEnabled()) { return mSwipeHelper.onInterceptTouchEvent(ev) || super.onInterceptTouchEvent(ev); } else { return super.onInterceptTouchEvent(ev); @@ -1009,7 +1014,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements @Override public boolean onTouchEvent(MotionEvent ev) { - if (mSwipeHelper != null) { + if (mSwipeHelper != null && isSwipeEnabled()) { return mSwipeHelper.onTouchEvent(ev) || super.onTouchEvent(ev); } else { return super.onTouchEvent(ev); @@ -1166,5 +1171,11 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements @Override public void onTouch() { removePendingContactEntry(); + return; + } + + @Override + public boolean isSwipeEnabled() { + return !mAwaitingRemove; } } diff --git a/src/com/android/dialer/list/SwipeHelper.java b/src/com/android/dialer/list/SwipeHelper.java index 3bcad2d95..f493c9dbb 100644 --- a/src/com/android/dialer/list/SwipeHelper.java +++ b/src/com/android/dialer/list/SwipeHelper.java @@ -465,5 +465,7 @@ public class SwipeHelper { public void onSwipe(View view); public void onTouch(); + + public boolean isSwipeEnabled(); } } \ No newline at end of file diff --git a/src/com/android/dialer/list/SwipeableListView.java b/src/com/android/dialer/list/SwipeableListView.java index 504b1403b..29c4f674b 100644 --- a/src/com/android/dialer/list/SwipeableListView.java +++ b/src/com/android/dialer/list/SwipeableListView.java @@ -76,7 +76,7 @@ public class SwipeableListView extends ListView implements SwipeHelperCallback { } public boolean isSwipeEnabled() { - return mEnableSwipe; + return mEnableSwipe && mOnItemGestureListener.isSwipeEnabled(); } public void setOnItemSwipeListener(OnItemGestureListener listener) { @@ -85,7 +85,7 @@ public class SwipeableListView extends ListView implements SwipeHelperCallback { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { - if (mEnableSwipe) { + if (isSwipeEnabled()) { return mSwipeHelper.onInterceptTouchEvent(ev) || super.onInterceptTouchEvent(ev); } else { return super.onInterceptTouchEvent(ev); @@ -97,7 +97,7 @@ public class SwipeableListView extends ListView implements SwipeHelperCallback { if (mOnItemGestureListener != null) { mOnItemGestureListener.onTouch(); } - if (mEnableSwipe) { + if (isSwipeEnabled()) { return mSwipeHelper.onTouchEvent(ev) || super.onTouchEvent(ev); } else { return super.onTouchEvent(ev); -- cgit v1.2.3