OSDN Git Service

Automated import from //branches/cupcake/...@142955,142955
authorJeffrey Sharkey <>
Thu, 26 Mar 2009 18:51:50 +0000 (11:51 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Thu, 26 Mar 2009 18:51:50 +0000 (11:51 -0700)
src/com/android/contacts/ViewContactActivity.java

index 571e2e4..28a82b4 100644 (file)
@@ -413,20 +413,23 @@ public class ViewContactActivity extends ListActivity
                     Bundle bundle = new Bundle();
                     String name = mCursor.getString(CONTACT_NAME_COLUMN);
                     if (!TextUtils.isEmpty(name)) {
+                        // Correctly handle when section headers are hidden
+                        int sepAdjust = SHOW_SEPARATORS ? 1 : 0;
+                        
                         bundle.putString(Contacts.Intents.Insert.NAME, name);
                         // The 0th ViewEntry in each ArrayList below is a separator item
-                        int entriesToAdd = Math.min(mPhoneEntries.size() - 1, PHONE_KEYS.length);
+                        int entriesToAdd = Math.min(mPhoneEntries.size() - sepAdjust, PHONE_KEYS.length);
                         for (int x = 0; x < entriesToAdd; x++) {
-                            ViewEntry entry = mPhoneEntries.get(x + 1);
+                            ViewEntry entry = mPhoneEntries.get(x + sepAdjust);
                             bundle.putString(PHONE_KEYS[x], entry.data);
                         }
-                        entriesToAdd = Math.min(mEmailEntries.size() - 1, EMAIL_KEYS.length);
+                        entriesToAdd = Math.min(mEmailEntries.size() - sepAdjust, EMAIL_KEYS.length);
                         for (int x = 0; x < entriesToAdd; x++) {
-                            ViewEntry entry = mEmailEntries.get(x + 1);
+                            ViewEntry entry = mEmailEntries.get(x + sepAdjust);
                             bundle.putString(EMAIL_KEYS[x], entry.data);
                         }
-                        if (mPostalEntries.size() >= 2) {
-                            ViewEntry entry = mPostalEntries.get(1);
+                        if (mPostalEntries.size() >= 1 + sepAdjust) {
+                            ViewEntry entry = mPostalEntries.get(sepAdjust);
                             bundle.putString(Contacts.Intents.Insert.POSTAL, entry.data);
                         }
                         intent.putExtra("ENCODE_DATA", bundle);