rx-contacts icon indicating copy to clipboard operation
rx-contacts copied to clipboard

How to make a search request ?

Open Pahanuch opened this issue 8 years ago • 0 comments

Hi. I need to filter "phoneNumbers" array. The code can take only the first element, but other skips. How to change my code to get expected result ? Thank you

public void loadContacts(Context context, String phoneField) {
        RxContacts
                .fetch(context)
                .filter(contact -> contact.inVisibleGroup == 1)
                .filter(contact -> !contact.phoneNumbers.isEmpty())
                .filter(contact -> contact.phoneNumbers.iterator().next().contains(phoneField) || contact.displayName.toLowerCase().contains(phoneField.toLowerCase()))
                .toSortedList((lhs, rhs) -> lhs.displayName.compareToIgnoreCase(rhs.displayName))
                .compose(RxUtils.async())
                .compose(mRxLoaderManager.restart(CONTACTS_LOADER))
                .subscribe(this::handleResponse, this::handleError, this::onCompleted);
    }

Pahanuch avatar Apr 22 '17 01:04 Pahanuch