Example usage for android.widget AlphabetIndexer AlphabetIndexer

List of usage examples for android.widget AlphabetIndexer AlphabetIndexer

Introduction

In this page you can find the example usage for android.widget AlphabetIndexer AlphabetIndexer.

Prototype

public AlphabetIndexer(Cursor cursor, int sortedColumnIndex, CharSequence alphabet) 

Source Link

Document

Constructs the indexer.

Usage

From source file:com.fututel.utils.contacts.ContactsSearchAdapter.java

@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    Cursor c = ContactsWrapper.getInstance().searchContact(mContext, constraint);

    if (alphaIndexer == null) {
        alphaIndexer = new AlphabetIndexer(c, ContactsWrapper.getInstance().getContactIndexableColumnIndex(c),
                " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    } else {/*from ww  w .jav  a 2  s  .c o  m*/
        alphaIndexer.setCursor(c);
    }
    return c;
}

From source file:com.csipsimple.utils.contacts.ContactsSearchAdapter.java

@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    Cursor c = ContactsWrapper.getInstance().getContactsPhones(mContext, constraint);

    if (alphaIndexer == null) {
        alphaIndexer = new AlphabetIndexer(c, ContactsWrapper.getInstance().getContactIndexableColumnIndex(c),
                " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    } else {//  w  w  w .  j a  va  2  s . co  m
        alphaIndexer.setCursor(c);
    }
    return c;
}

From source file:fr.eoit.activity.util.AmazingSimpleCursorAdapter.java

@Override
public Cursor swapCursor(Cursor c) {
    // Create our indexer
    if (c != null && c.getCount() > INDEXER_LINE_THRESHOLD) {
        switch (orderType) {
        case NAME_ALPHA:
            defaultIndexer = new AlphabetIndexer(c, c.getColumnIndexOrThrow(alphaColumnName),
                    " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            break;

        case CATEGORY:
            defaultIndexer = new CategoryIndexer(c);
            break;

        default://from www  . ja  v  a  2 s  .com
            break;
        }
    } else {
        defaultIndexer = null;
    }

    return super.swapCursor(c);
}

From source file:org.linphone.ContactsFragment.java

private void searchContacts(String search) {
    if (search == null || search.length() == 0) {
        changeContactsAdapter();//from  ww  w .  ja  v  a2  s.  c o m
        return;
    }
    changeContactsToggle();

    if (searchCursor != null) {
        searchCursor.close();
    }

    if (onlyDisplayLinphoneContacts) {
        searchCursor = Compatibility.getSIPContactsCursor(getActivity().getContentResolver(), search,
                ContactsManager.getInstance().getContactsId());
        indexer = new AlphabetIndexer(searchCursor, Compatibility.getCursorDisplayNameColumnIndex(searchCursor),
                " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        contactsList.setAdapter(new ContactsListAdapter(null, searchCursor));
    } else {
        searchCursor = Compatibility.getContactsCursor(getActivity().getContentResolver(), search,
                ContactsManager.getInstance().getContactsId());
        indexer = new AlphabetIndexer(searchCursor, Compatibility.getCursorDisplayNameColumnIndex(searchCursor),
                " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        contactsList.setAdapter(new ContactsListAdapter(null, searchCursor));
    }
}

From source file:org.linphone.ContactsListFragment.java

private void searchContacts(String search) {
    if (search == null || search.length() == 0) {
        changeContactsAdapter();//  w w w .jav  a2s .  com
        return;
    }

    if (searchCursor != null) {
        searchCursor.close();
    }
    if (onlyDisplayLinphoneContacts) {
        searchCursor = Compatibility.getSIPContactsCursor(getActivity().getContentResolver(), search,
                ContactsManager.getInstance().getContactsId());
        indexer = new AlphabetIndexer(searchCursor, Compatibility.getCursorDisplayNameColumnIndex(searchCursor),
                " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
        contactsList.setAdapter(new ContactsListAdapter(null, searchCursor));
    } else {
        searchCursor = Compatibility.getContactsCursor(getActivity().getContentResolver(), search,
                ContactsManager.getInstance().getContactsId());
        contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
        indexer = new AlphabetIndexer(searchCursor, Compatibility.getCursorDisplayNameColumnIndex(searchCursor),
                " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        contactsList.setAdapter(new ContactsListAdapter(null, searchCursor));
    }

}

From source file:org.linphone.ContactsFragment.java

private void changeContactsAdapter() {
    changeContactsToggle();// w  w w  .j  a  va  2  s .  c  o  m

    if (searchCursor != null) {
        searchCursor.close();
    }

    Cursor allContactsCursor = ContactsManager.getInstance().getAllContactsCursor();
    Cursor sipContactsCursor = ContactsManager.getInstance().getSIPContactsCursor();

    noSipContact.setVisibility(View.GONE);
    noContact.setVisibility(View.GONE);
    contactsList.setVisibility(View.VISIBLE);

    if (onlyDisplayLinphoneContacts) {
        if (sipContactsCursor != null && sipContactsCursor.getCount() == 0) {
            noSipContact.setVisibility(View.VISIBLE);
            contactsList.setVisibility(View.GONE);
        } else {
            indexer = new AlphabetIndexer(sipContactsCursor,
                    Compatibility.getCursorDisplayNameColumnIndex(sipContactsCursor),
                    " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            contactsList.setAdapter(
                    new ContactsListAdapter(ContactsManager.getInstance().getSIPContacts(), sipContactsCursor));
        }
    } else {
        if (allContactsCursor != null && allContactsCursor.getCount() == 0) {
            noContact.setVisibility(View.VISIBLE);
            contactsList.setVisibility(View.GONE);
        } else {
            indexer = new AlphabetIndexer(allContactsCursor,
                    Compatibility.getCursorDisplayNameColumnIndex(allContactsCursor),
                    " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            contactsList.setAdapter(
                    new ContactsListAdapter(ContactsManager.getInstance().getAllContacts(), allContactsCursor));
        }
    }
    ContactsManager.getInstance().setLinphoneContactsPrefered(onlyDisplayLinphoneContacts);
}

From source file:com.csipsimple.utils.contacts.ContacksSearchGridAdapter.java

@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    Cursor c = ContactsWrapper.getInstance().getContactsPhones(mContext, constraint);

    if (alphaIndexer == null) {
        alphaIndexer = new AlphabetIndexer(c, ContactsWrapper.getInstance().getContactIndexableColumnIndex(c),
                " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    } else {/*w w  w  .ja va 2 s  .  c o m*/
        alphaIndexer.setCursor(c);
    }

    return c;
}

From source file:org.linphone.ContactsListFragment.java

private void changeContactsAdapter() {

    if (searchCursor != null) {
        searchCursor.close();/*from w ww.jav a  2  s  .c o  m*/
    }

    Cursor allContactsCursor = ContactsManager.getInstance().getAllContactsCursor();
    Cursor sipContactsCursor = ContactsManager.getInstance().getSIPContactsCursor();

    noSipContact.setVisibility(View.GONE);
    noContact.setVisibility(View.GONE);
    contactsList.setVisibility(View.VISIBLE);
    if (onlyDisplayLinphoneContacts) {
        if (sipContactsCursor != null && sipContactsCursor.getCount() == 0) {
            noSipContact.setVisibility(View.VISIBLE);
            contactsList.setVisibility(View.GONE);
        } else if (sipContactsCursor != null) {
            indexer = new AlphabetIndexer(sipContactsCursor,
                    Compatibility.getCursorDisplayNameColumnIndex(sipContactsCursor),
                    " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
            contactsList.setAdapter(
                    new ContactsListAdapter(ContactsManager.getInstance().getSIPContacts(), sipContactsCursor));

        }
    } else {
        if (allContactsCursor != null && allContactsCursor.getCount() == 0) {
            noContact.setVisibility(View.VISIBLE);
            contactsList.setVisibility(View.GONE);
        } else if (allContactsCursor != null) {
            indexer = new AlphabetIndexer(allContactsCursor,
                    Compatibility.getCursorDisplayNameColumnIndex(allContactsCursor),
                    " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            //contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
            List<Contact> allContacts = ContactsManager.getInstance().getAllContacts();
            //               Collections.sort(allContacts, new Comparator<Contact>() {
            //
            //                     /* This comparator will sort AppDetail objects alphabetically. */
            //
            //                  @Override
            //                  public int compare(Contact a1, Contact a2) {
            //                     // String implements Comparable
            //                     return (a1.getName()).compareTo(a2.getName());
            //                  }
            //               });
            contactsList.setAdapter(new ContactsListAdapter(allContacts, allContactsCursor));
        }
    }
    Log.e("list size:" + allContactsCursor.getCount());
    //ContactsManager.getInstance().setLinphoneContactsPrefered(onlyDisplayLinphoneContacts);
}

From source file:org.xingjitong.ContactsFragment.java

@SuppressWarnings("unchecked")
private void changeContactsAdapter() {
    changeContactsToggle();//from www. j  a v a2s . co m
    // ------------
    Cursor allContactsCursor = null, sipContactsCursor = null;
    if (LinphoneActivity.isInstanciated())
        allContactsCursor = LinphoneActivity.instance().getAllContactsCursor();
    if (LinphoneActivity.isInstanciated())
        sipContactsCursor = LinphoneActivity.instance().getSIPContactsCursor();
    if (allContactsCursor == null || sipContactsCursor == null) {
        return;
    }
    if (noSipContact != null)
        noSipContact.setVisibility(View.GONE);
    if (noContact != null)
        noContact.setVisibility(View.GONE);
    if (contactsList != null)
        contactsList.setVisibility(View.VISIBLE);

    if (onlyDisplayLinphoneContacts) {
        if (sipContactsCursor.getCount() == 0) {
            if (noSipContact != null)
                noSipContact.setVisibility(View.VISIBLE);
            if (abc != null)
                abc.setVisibility(View.GONE);
            if (contactsList != null)
                contactsList.setVisibility(View.GONE);
        } else {
            if (abc != null)
                abc.setVisibility(View.VISIBLE);
            indexer = new AlphabetIndexer(sipContactsCursor,
                    Compatibility.getCursorDisplayNameColumnIndex(sipContactsCursor),
                    " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            setAbcAdapter(1);
            List<Contact> lists;
            if (os != null)
                lists = (List<Contact>) os[2];
            else
                lists = new ArrayList<Contact>();
            ContactsListAdapter adapter = new ContactsListAdapter(lists, this.bitmapUnknown, margin);
            if (contactsList != null)
                contactsList.setAdapter(adapter);// sipContactsCursor
        }
    } else {
        if (allContactsCursor.getCount() == 0) {
            if (noContact != null)
                noContact.setVisibility(View.VISIBLE);
            if (contactsList != null)
                contactsList.setVisibility(View.GONE);
            if (abc != null)
                abc.setVisibility(View.GONE);
        } else {
            if (abc != null)
                abc.setVisibility(View.VISIBLE);
            indexer = new AlphabetIndexer(allContactsCursor,
                    Compatibility.getCursorDisplayNameColumnIndex(allContactsCursor),
                    " ABCDEFGHIJKLMNOPQRSTUVWXYZ");
            setAbcAdapter(0);
            List<Contact> lists;
            if (os != null)
                lists = (List<Contact>) os[2];
            else
                lists = new ArrayList<Contact>();
            ContactsListAdapter adapter = new ContactsListAdapter(lists, this.bitmapUnknown, margin);
            if (contactsList != null)
                contactsList.setAdapter(adapter);// , allContactsCursor
        }
    }
    LinphoneActivity.instance().setLinphoneContactsPrefered(onlyDisplayLinphoneContacts);
    allContactsCursor.close();
    sipContactsCursor.close();
}