Search in sources :

Example 1 with Contact

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;
}
Also used : OnUpcomingEventClickedListener(com.alexstyl.specialdates.upcoming.view.OnUpcomingEventClickedListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) UpcomingEventsView(com.alexstyl.specialdates.UpcomingEventsView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Date(com.alexstyl.specialdates.date.Date) Contact(com.alexstyl.specialdates.contact.Contact)

Example 2 with Contact

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);
}
Also used : ContactEvent(com.alexstyl.specialdates.date.ContactEvent) Date(com.alexstyl.specialdates.date.Date) Contact(com.alexstyl.specialdates.contact.Contact) Test(org.junit.Test)

Example 3 with 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;
}
Also used : ContactEvent(com.alexstyl.specialdates.date.ContactEvent) ArrayList(java.util.ArrayList) Contact(com.alexstyl.specialdates.contact.Contact)

Example 4 with Contact

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();
}
Also used : ContactsProvider(com.alexstyl.specialdates.contact.ContactsProvider) Contact(com.alexstyl.specialdates.contact.Contact) Test(org.junit.Test)

Example 5 with Contact

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);
}
Also used : ContactsProvider(com.alexstyl.specialdates.contact.ContactsProvider) Contact(com.alexstyl.specialdates.contact.Contact) Test(org.junit.Test)

Aggregations

Contact (com.alexstyl.specialdates.contact.Contact)21 Test (org.junit.Test)10 ContactEvent (com.alexstyl.specialdates.date.ContactEvent)9 ArrayList (java.util.ArrayList)8 Date (com.alexstyl.specialdates.date.Date)6 ContactsProvider (com.alexstyl.specialdates.contact.ContactsProvider)5 ContactEventsOnADate (com.alexstyl.specialdates.events.peopleevents.ContactEventsOnADate)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 UpcomingEventsView (com.alexstyl.specialdates.UpcomingEventsView)2 DisplayName (com.alexstyl.specialdates.contact.DisplayName)2 Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 ContentValues (android.content.ContentValues)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 Nullable (android.support.annotation.Nullable)1 NotificationCompat (android.support.v4.app.NotificationCompat)1