use of com.alexstyl.specialdates.date.ContactEvent in project Memento-Calendar by alexstyl.
the class EventLabelCreatorTest method otherIsCalculatedCorrectly.
@Test
public void otherIsCalculatedCorrectly() {
Date date = Date.Companion.on(12, DECEMBER);
ContactEvent event = contactEventOn(date, OTHER);
String label = creator.createFor(event);
assertThat(label).isEqualTo("Other on December 12");
}
use of com.alexstyl.specialdates.date.ContactEvent in project Memento-Calendar by alexstyl.
the class ContactActionTest method testReturnedContactsSizeIsCorrect.
@Test
public void testReturnedContactsSizeIsCorrect() {
Date date = Date.Companion.on(1, JANUARY, 2016);
ArrayList<ContactEvent> contactEvent = new ArrayList<>();
contactEvent.add(EVENT_ONE);
contactEvent.add(EVENT_TWO);
ContactEventsOnADate events = ContactEventsOnADate.Companion.createFrom(date, contactEvent);
List<Contact> contacts = events.getContacts();
assertThat(contacts.size()).isEqualTo(2);
}
use of com.alexstyl.specialdates.date.ContactEvent in project Memento-Calendar by alexstyl.
the class FacebookFriendsIntentService method onHandleIntent.
@Override
protected void onHandleIntent(@Nullable Intent intent) {
FacebookCalendarLoader calendarLoader = new FacebookCalendarLoader();
FacebookContactFactory factory = new FacebookContactFactory(parser);
ContactEventSerialiser serialiser = new ContactEventSerialiser(factory, tracker);
FacebookBirthdaysProvider calendarFetcher = new FacebookBirthdaysProvider(calendarLoader, serialiser);
UserCredentials userCredentials = facebookUserSettings.retrieveCredentials();
if (isAnnonymous(userCredentials)) {
tracker.track(new RuntimeException("Tried to fetch events, but was anonymous"));
return;
}
CalendarURLCreator calendarURLCreator = new CalendarURLCreator(tracker);
URL calendarUrl = calendarURLCreator.createFrom(userCredentials);
FacebookFriendsPersister persister = new FacebookFriendsPersister(new AndroidPeopleEventsPersister(new EventSQLiteOpenHelper(this), marshaller, tracker));
try {
List<ContactEvent> friends = calendarFetcher.fetchCalendarFrom(calendarUrl);
persister.keepOnly(friends);
uiRefresher.refreshViews();
} catch (CalendarFetcherException e) {
tracker.track(e);
}
if (BuildConfig.DEBUG) {
notifyServiceRan();
}
}
use of com.alexstyl.specialdates.date.ContactEvent in project Memento-Calendar by alexstyl.
the class ContactEventsMarshaller method marshall.
public ContentValues[] marshall(List<ContactEvent> item) {
ContentValues[] returningValues = new ContentValues[item.size()];
for (int i = 0; i < item.size(); i++) {
ContactEvent event = item.get(i);
returningValues[i] = createValuesFor(event);
}
return returningValues;
}
use of com.alexstyl.specialdates.date.ContactEvent in project Memento-Calendar by alexstyl.
the class ContactEventsLoader method createModelsFor.
private List<AddEventContactEventViewModel> createModelsFor(Contact contact) {
List<AddEventContactEventViewModel> existingViewModels;
List<ContactEvent> contactEvents = new ArrayList<>();
List<ContactEvent> contactEventsOnDate = peopleEventsProvider.fetchEventsBetween(TimePeriod.Companion.aYearFromNow());
List<EventType> existingTypes = new ArrayList<>();
for (ContactEvent contactEvent : contactEventsOnDate) {
if (contactEvent.getContact().getContactID() == contact.getContactID() && isEditable(contactEvent)) {
contactEvents.add(contactEvent);
existingTypes.add(contactEvent.getType());
}
}
existingViewModels = factory.createViewModel(contactEvents);
List<AddEventContactEventViewModel> emptyViewModels = newEventFactory.createViewModelsForAllEventsBut(existingTypes);
existingViewModels.addAll(emptyViewModels);
return existingViewModels;
}
Aggregations