Java Code Examples for com.android.contacts.Collapser

Following code examples demonstrate how to use com.android.contacts.Collapserfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.android.contacts.Collapserand various code implementation of this class.

    public void onLoadComplete(Loader<Cursor> loader, Cursor cursor) {
        if (cursor == null || !isSafeToCommitTransactions()) {
            onDismiss();
            return;
        }

        ArrayList<PhoneItem> phoneList = new ArrayList<PhoneItem>();
        String primaryPhone = null;
        try {
            while (cursor.moveToNext()) {
                if (cursor.getInt(cursor.getColumnIndex(Phone.IS_SUPER_PRIMARY)) != 0) {
                    primaryPhone = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));
                    break;
                }

                PhoneItem item = new PhoneItem();
                item.id = cursor.getLong(cursor.getColumnIndex(Data._ID));
                item.phoneNumber = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));
                item.accountType =
                        cursor.getString(cursor.getColumnIndex(RawContacts.ACCOUNT_TYPE));
                item.dataSet = cursor.getString(cursor.getColumnIndex(RawContacts.DATA_SET));
                item.type = cursor.getInt(cursor.getColumnIndex(Phone.TYPE));
                item.label = cursor.getString(cursor.getColumnIndex(Phone.LABEL));
                item.mimeType = cursor.getString(cursor.getColumnIndex(Phone.MIMETYPE));

                phoneList.add(item);
            }
        } finally {
            Worker w = Worker.getWorkerInstance();
            if (w != null) {
                w.prepair();
                w.postJob(new Worker.WrapperCloseCursor(cursor));
            } else {
                cursor.close();
            }
        }

        if (primaryPhone != null) {
            performAction(primaryPhone);
            onDismiss();
            return;
        }

        Collapser.collapseList(phoneList);

        if (phoneList.size() == 0) {
            onDismiss();
        } else if (phoneList.size() == 1) {
            PhoneItem item = phoneList.get(0);
            onDismiss();
            performAction(item.phoneNumber);
        } else {
            showDisambiguationDialog(phoneList);
        }
    } 


Advertisement
Javadoc
Class used for collapsing data items into groups of similar items. The data items that should be col

lapsible should implement the Collapsible interface. The class also contains a utility function that takes an ArrayList of items and returns a list of the same items collapsed into groups.

Read More
Advertisement