Delay closing the alternates popup when the user selects an alternate.
Per UX, this gives the user a better idea of what has just occured.
Using temporary assets.
Change-Id: Ied49f899d7999356cc01a672ecb22f492901d55c
diff --git a/src/com/android/ex/chips/RecipientAlternatesAdapter.java b/src/com/android/ex/chips/RecipientAlternatesAdapter.java
index 335ba1d..3d2c87b 100644
--- a/src/com/android/ex/chips/RecipientAlternatesAdapter.java
+++ b/src/com/android/ex/chips/RecipientAlternatesAdapter.java
@@ -33,19 +33,17 @@
private final int mLayoutId;
- private final int mSelectedLayoutId;
-
private final long mCurrentId;
- public RecipientAlternatesAdapter(Context context, long contactId, long currentId, int viewId,
- int selectedViewId) {
+ private int mCheckedItemPosition = -1;
+
+ public RecipientAlternatesAdapter(Context context, long contactId, long currentId, int viewId) {
super(context, context.getContentResolver().query(Email.CONTENT_URI, EmailQuery.PROJECTION,
Email.CONTACT_ID + " =?", new String[] {
String.valueOf(contactId)
}, null), 0);
mLayoutInflater = LayoutInflater.from(context);
mLayoutId = viewId;
- mSelectedLayoutId = selectedViewId;
mCurrentId = currentId;
}
@@ -69,7 +67,10 @@
Cursor cursor = getCursor();
cursor.moveToPosition(position);
if (convertView == null) {
- convertView = newView(cursor.getLong(EmailQuery.DATA_ID) == mCurrentId);
+ convertView = newView();
+ }
+ if (cursor.getLong(EmailQuery.DATA_ID) == mCurrentId) {
+ mCheckedItemPosition = position;
}
bindView(convertView, convertView.getContext(), cursor);
return convertView;
@@ -101,11 +102,17 @@
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
- return newView(false);
+ return newView();
}
- private View newView(boolean isSelected) {
- return isSelected ? mLayoutInflater.inflate(mSelectedLayoutId, null) : mLayoutInflater
- .inflate(mLayoutId, null);
+ private View newView() {
+ return mLayoutInflater.inflate(mLayoutId, null);
+ }
+
+ /**
+ * Get the position of the item that should be checked.
+ */
+ public int getCheckedItemPosition() {
+ return mCheckedItemPosition;
}
}