Search in sources :

Example 11 with Contact

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

Example 12 with Contact

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;
}
Also used : ContentValues(android.content.ContentValues) Contact(com.alexstyl.specialdates.contact.Contact)

Example 13 with Contact

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

Example 14 with Contact

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

Example 15 with Contact

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();
}
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