use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class PeopleFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fragment_people, container, false);
loadingView = inflate.findViewById(R.id.people_loading);
recyclerView = inflate.findViewById(R.id.people_list);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
adapter = new PeopleAdapter(imageLoader, inflater, new PeopleViewHolderListener() {
@Override
public void onPersonClicked(Contact contact) {
navigator.toContactDetails(contact, getActivity());
}
@Override
public void onFacebookImport() {
navigator.toFacebookImport(getActivity());
}
@Override
public void onAddContactClicked() {
navigator.toAddEvent(getActivity(), HomeActivity.CODE_ADD_EVENT);
}
});
recyclerView.setAdapter(adapter);
recyclerView.addItemDecoration(new PeopleItemDecorator(getResources().getDimensionPixelSize(R.dimen.people_import_bottom_spacing), getResources().getDimensionPixelSize(R.dimen.people_inbetween_spacing)));
return inflate;
}
use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class ContactEventsMarshaller method createValuesFor.
private ContentValues createValuesFor(ContactEvent event) {
Contact contact = event.getContact();
ContentValues values = new ContentValues(DEFAULT_VALUES_SIZE);
values.put(AnnualEventsContract.CONTACT_ID, contact.getContactID());
values.put(AnnualEventsContract.DISPLAY_NAME, contact.getDisplayName().toString());
values.put(AnnualEventsContract.DATE, dateLabelCreator.createLabelWithYearPreferredFor(event.getDate()));
values.put(AnnualEventsContract.EVENT_TYPE, event.getType().getId());
values.put(AnnualEventsContract.SOURCE, contact.getSource());
values.put(AnnualEventsContract.VISIBLE, IS_VISIBILE);
putDeviceContactIdIfPresent(event, values);
return values;
}
use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class ContactsAdapter method getView.
@Override
public View getView(int position, View view, ViewGroup parent) {
ContactViewHolder vh;
if (view == null) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_contact, parent, false);
vh = new ContactViewHolder();
vh.contactName = Views.findById(view, R.id.display_name);
vh.avatar = Views.findById(view, R.id.search_result_avatar);
view.setTag(vh);
} else {
vh = (ContactViewHolder) view.getTag();
}
Contact contact = getItem(position);
String displayName = contact.toString();
vh.contactName.setText(displayName);
vh.avatar.setCircleColorVariant((int) contact.getContactID());
vh.avatar.setLetter(displayName);
imageLoader.load(contact.getImagePath()).asCircle().into(vh.avatar.getImageView());
return view;
}
use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class ContactsSearchTest method canFindSurname.
@Test
public void canFindSurname() {
ContactsProvider contactsProvider = mock(ContactsProvider.class);
when(contactsProvider.getAllContacts()).thenReturn(contacts("Alex Styl", "Alex Evil Twin", "Anna Papadopoulou"));
ContactsSearch search = new ContactsSearch(contactsProvider, NameMatcher.INSTANCE);
List<Contact> oneContact = search.searchForContacts("Papadopoulou", 1);
assertThat(oneContact.size()).isEqualTo(1);
assertThat(oneContact.get(0).getDisplayName().toString()).isEqualTo("Anna Papadopoulou");
}
use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class ContactsSearchTest method returnEmptyForNoMatches.
@Test
public void returnEmptyForNoMatches() {
ContactsProvider contactsProvider = mock(ContactsProvider.class);
when(contactsProvider.getAllContacts()).thenReturn(contacts("Alex Styl", "Alex Evil Twin", "Anna Papadopoulou"));
ContactsSearch search = new ContactsSearch(contactsProvider, NameMatcher.INSTANCE);
List<Contact> results = search.searchForContacts("there is no contact with a name like this", 1);
assertThat(results).isEmpty();
}
Aggregations