Don't display count for items with invalid IDs

Change-Id: Id82b0a96a718f27d51d205b066a282444d6bd939
This commit is contained in:
Todd Kennedy 2011-06-08 15:40:52 -07:00
parent 85bd26e210
commit a26fe0f150

View File

@ -117,6 +117,21 @@ public class AccountSelectorAdapter extends CursorAdapter {
return super.getView(position, convertView, parent); return super.getView(position, convertView, parent);
} }
/**
* The account selector view can contain one of four types of row data:
* <ol>
* <li>headers</li>
* <li>accounts</li>
* <li>recent mailboxes</li>
* <li>"show all folders"</li>
* </ol>
* Headers are handled separately as they have a unique layout and cannot be interacted with.
* Accounts, recent mailboxes and "show all folders" all have the same interaction model and
* share a very similar layout. The single difference is that both accounts and recent
* mailboxes display an unread count; whereas "show all folders" does not. To determine
* if a particular row is "show all folders" verify that a) it's not an account row and
* b) it's ID is {@link Mailbox#NO_MAILBOX}.
*/
@Override @Override
public View getDropDownView(int position, View convertView, ViewGroup parent) { public View getDropDownView(int position, View convertView, ViewGroup parent) {
Cursor c = getCursor(); Cursor c = getCursor();
@ -147,8 +162,13 @@ public class AccountSelectorAdapter extends CursorAdapter {
emailAddressView.setText(emailAddress); emailAddressView.setText(emailAddress);
} }
if (isAccountItem(position) || getAccountId(c) != Mailbox.NO_MAILBOX) {
unreadCountView.setVisibility(View.VISIBLE);
unreadCountView.setText(UiUtilities.getMessageCountForUi(mContext, unreadCountView.setText(UiUtilities.getMessageCountForUi(mContext,
getAccountUnreadCount(position), false)); getAccountUnreadCount(position), false));
} else {
unreadCountView.setVisibility(View.INVISIBLE);
}
} }
return view; return view;
} }