use of com.alexstyl.specialdates.contact.DisplayName in project Memento-Calendar by alexstyl.
the class FacebookContactFactory method createContactFrom.
ContactEvent createContactFrom(Map<String, String> map) throws InvalidFacebookContactException {
try {
Date date = dateFrom(map);
DisplayName name = nameFrom(map);
long uid = idOf(map);
URI imagePath = FacebookImagePath.INSTANCE.forUid(uid);
return new ContactEvent(Optional.Companion.<Long>absent(), StandardEventType.BIRTHDAY, date, new Contact(uid, name, imagePath, SOURCE_FACEBOOK));
} catch (DateParseException | IndexOutOfBoundsException ex) {
throw new InvalidFacebookContactException(ex);
}
}
use of com.alexstyl.specialdates.contact.DisplayName in project Memento-Calendar by alexstyl.
the class ContactsSearch method searchForContacts.
List<Contact> searchForContacts(String searchQuery, int numberOfResults) {
List<Contact> matchedContacts = new ArrayList<>();
if (numberOfResults == 0) {
return matchedContacts;
}
searchQuery = searchQuery.trim();
List<Contact> allContacts = contactsProvider.getAllContacts();
if (allContacts.size() == 0) {
return matchedContacts;
}
int count = 0;
int index = 0;
int contactSize = allContacts.size();
do {
Contact contact = allContacts.get(index);
DisplayName displayName = contact.getDisplayName();
if (nameMatcher.match(displayName, searchQuery)) {
matchedContacts.add(contact);
count++;
}
index++;
} while (count < numberOfResults && index < contactSize);
return matchedContacts;
}
Aggregations