private void startGroupDetails(Recipient recipient) { String groupType = recipient.getGroupType(); if (groupType.equalsIgnoreCase(LocalGroupDetailsActivity.LOCAL)) { startLocalGroupDetails(recipient); } else { startGroupDetailsService(recipient); } }
private LinkedHashMap<String, List<IHolderSource>> getIndexableContactsList(Cursor cursor) { String[] sectionTitles = { "Favorites", "Groups", "#", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; LinkedHashMap<String, List<IHolderSource>> tableDataMap = new LinkedHashMap<String, List<IHolderSource>>(); for (String title : sectionTitles) { tableDataMap.put(title, new ArrayList<IHolderSource>()); } if (cursor.moveToFirst()) { do { Recipient recipient = Recipient.createFromDepartmentCursor(cursor); // Don't add currently logged in user as a contact if (recipient .getSmartPagerId() .equalsIgnoreCase( SmartPagerApplication.getInstance().getPreferences().getSmartPagerID())) continue; if (recipient.isGroup()) { tableDataMap.get("Groups").add(recipient); } else { // trim() to account for any last names that have a leading space String firstChar = recipient.getLastName().trim().substring(0, 1).toUpperCase(); if (Arrays.asList(sectionTitles).contains(firstChar)) { tableDataMap.get(firstChar).add(recipient); } } if (SmartPagerApplication.getInstance() .isFavourite(getActivity().getApplicationContext(), recipient.getSmartPagerId())) { tableDataMap.get("Favorites").add(recipient); } if (recipient.getGroupType().equalsIgnoreCase("LOCAL")) { tableDataMap.get("Favorites").add(recipient); } } while (cursor.moveToNext()); } // Only sort Favorites and Groups, the rest of the sections appear to sort properly. Collections.sort(tableDataMap.get("Favorites"), new RecipientsGroupsComparator()); Collections.sort(tableDataMap.get("Groups"), new RecipientsGroupsComparator()); return tableDataMap; }