use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class UpcomingEventsFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_upcoming_events, container, false);
root = Views.findById(view, R.id.root);
progressBar = Views.findById(view, R.id.upcoming_events_progress);
emptyView = Views.findById(view, R.id.upcoming_events_emptyview);
upcomingList = Views.findById(view, R.id.upcoming_events_list);
upcomingList.setHasFixedSize(true);
upcomingList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
upcomingList.addItemDecoration(new UpcomingEventsDecorator(getResources().getDimensionPixelSize(R.dimen.upcoming_event_header_vertical_spacing), getResources().getDimensionPixelSize(R.dimen.upcoming_event_vertical_spacing)));
adapter = new UpcomingEventsAdapter(new UpcomingViewHolderFactory(inflater, imageLoader), new OnUpcomingEventClickedListener() {
@Override
public void onContactClicked(Contact contact) {
navigator.toContactDetails(contact, getActivity());
}
@Override
public void onNamedayClicked(Date date) {
navigator.toDateDetails(date, getActivity());
}
});
adapter.setHasStableIds(true);
upcomingList.setAdapter(adapter);
return view;
}
use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class PeopleDynamicNamedaysProviderTest method gettingSpecialNamedaysOnSpecificDateOnlyReturnsTheEventsForThatDate.
@Test
public void gettingSpecialNamedaysOnSpecificDateOnlyReturnsTheEventsForThatDate() {
List<Contact> testContacts = createSomeContacts();
testContacts.add(EASTER_CELEBRATING_CONTACT);
when(mockContactsProvider.getAllContacts()).thenReturn(testContacts);
Date easterDate = OrthodoxEasterCalculator.INSTANCE.calculateEasterForYear(YEAR);
List<ContactEvent> contactEvents = calculator.fetchEventsBetween(TimePeriod.Companion.between(easterDate, easterDate));
assertThat(contactEvents).hasSize(1);
assertThat(contactEvents.get(0).getContact()).isEqualTo(EASTER_CELEBRATING_CONTACT);
}
use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class ContactOperations method getAllDeviceEventsFor.
private List<ContactEvent> getAllDeviceEventsFor(Contact contact) {
List<ContactEvent> contactEvents = new ArrayList<>();
List<ContactEvent> contactEventsOnDate = peopleEventsProvider.fetchEventsBetween(TimePeriod.Companion.aYearFromNow());
for (ContactEvent contactEvent : contactEventsOnDate) {
Contact dbContact = contactEvent.getContact();
if (dbContact.getContactID() == contact.getContactID() && contactEvent.getType() != StandardEventType.NAMEDAY) {
contactEvents.add(contactEvent);
}
}
return contactEvents;
}
use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class ContactsSearchTest method returnEmptyForNoContacts.
@Test
public void returnEmptyForNoContacts() {
ContactsProvider contactsProvider = mock(ContactsProvider.class);
when(contactsProvider.getAllContacts()).thenReturn(Collections.<Contact>emptyList());
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();
}
use of com.alexstyl.specialdates.contact.Contact in project Memento-Calendar by alexstyl.
the class ContactsSearchTest method ensureThatCounterIsRespected.
@Test
public void ensureThatCounterIsRespected() {
ContactsProvider contactsProvider = mock(ContactsProvider.class);
when(contactsProvider.getAllContacts()).thenReturn(contacts("Alex Styl", "Alex Evil Twin"));
ContactsSearch search = new ContactsSearch(contactsProvider, NameMatcher.INSTANCE);
List<Contact> oneContact = search.searchForContacts("Alex", 1);
assertThat(oneContact.size()).isEqualTo(1);
List<Contact> twoContacts = search.searchForContacts("Alex", 2);
assertThat(twoContacts.size()).isEqualTo(2);
}
Aggregations