类android.provider.ContactsContract.CommonDataKinds.Im源码实例Demo

下面列出了怎么用android.provider.ContactsContract.CommonDataKinds.Im的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: AndroidContacts   文件: ContactsGetter.java
private SparseArray<List<IMAddress>> getIMAddressesMap() {
    SparseArray<List<IMAddress>> idImAddressMap = new SparseArray<>();
    Cursor cur = getCursorFromContentType(new String[]{ID_KEY, MAIN_DATA_KEY, Im.PROTOCOL, Im.CUSTOM_PROTOCOL}, Im.CONTENT_ITEM_TYPE);
    if (cur != null) {
        while (cur.moveToNext()) {
            int id = cur.getInt(cur.getColumnIndex(ID_KEY));
            String data = cur.getString(cur.getColumnIndex(MAIN_DATA_KEY));
            int labelId = cur.getInt(cur.getColumnIndex(Im.PROTOCOL));
            String customLabel = cur.getString(cur.getColumnIndex(Im.CUSTOM_PROTOCOL));
            IMAddress current;
            if (customLabel == null)
                current = new IMAddress(mCtx, data, labelId);
            else
                current = new IMAddress(data, customLabel);
            List<IMAddress> currentWebsiteList = idImAddressMap.get(id);
            if (currentWebsiteList == null) {
                currentWebsiteList = new ArrayList<>();
                currentWebsiteList.add(current);
                idImAddressMap.put(id, currentWebsiteList);
            } else currentWebsiteList.add(current);
        }
        cur.close();
    }
    return idImAddressMap;
}
 
源代码2 项目: ContactMerger   文件: ImMetadata.java
/**
 * Retrieve the Protocol instance for a given raw database value.
 * @param id The raw database value.
 * @return The corresponding Protocol instance, or null.
 */
public static Protocol byProtocolId(int id) {
    switch(id) {
    case Im.PROTOCOL_CUSTOM: return CUSTOM;
    case Im.PROTOCOL_AIM: return AIM;
    case Im.PROTOCOL_MSN: return MSN;
    case Im.PROTOCOL_YAHOO: return YAHOO;
    case Im.PROTOCOL_SKYPE: return SKYPE;
    case Im.PROTOCOL_QQ: return QQ;
    case Im.PROTOCOL_GOOGLE_TALK: return GOOGLE_TALK;
    case Im.PROTOCOL_ICQ: return ICQ;
    case Im.PROTOCOL_JABBER: return JABBER;
    case Im.PROTOCOL_NETMEETING: return NETMEETING;
    }
    return null;
}
 
private String getProtocolName(String protocolId, String customProtocol) {
    if (protocolId == null) {
        throw new InvalidCursorTypeException();
    }
    switch (Integer.valueOf(protocolId)) {
        case Im.PROTOCOL_AIM:
            return "AIM";
        case Im.PROTOCOL_MSN:
            return "MSN";
        case Im.PROTOCOL_YAHOO:
            return "Yahoo";
        case Im.PROTOCOL_SKYPE:
            return "Skype";
        case Im.PROTOCOL_QQ:
            return "QQ";
        case Im.PROTOCOL_GOOGLE_TALK:
            return "Google Talk";
        case Im.PROTOCOL_ICQ:
            return "ICQ";
        case Im.PROTOCOL_JABBER:
            return "Jabber";
        case Im.PROTOCOL_NETMEETING:
            return "NetMeeting";
        case Im.PROTOCOL_CUSTOM:
            return customProtocol;
        default:
            return "Other";

    }
}
 
源代码4 项目: tindroid   文件: ContactOperations.java
/**
 * Adds a tinode im address
 *
 * @param tinode_id address we're adding
 * @return instance of ContactOperations
 */
@SuppressWarnings("unused")
ContactOperations addIm(final String tinode_id) {
    mValues.clear();
    if (!TextUtils.isEmpty(tinode_id)) {
        mValues.put(Im.DATA, tinode_id);
        mValues.put(Im.TYPE, Im.TYPE_OTHER);
        mValues.put(Im.MIMETYPE, Im.CONTENT_ITEM_TYPE);
        mValues.put(Im.PROTOCOL, Im.PROTOCOL_CUSTOM);
        mValues.put(Im.CUSTOM_PROTOCOL, Utils.TINODE_IM_PROTOCOL);
        addInsertOp();
    }
    return this;
}
 
源代码5 项目: ContactMerger   文件: ImMetadata.java
/**
 * Retrieve a type instalce for a given database value, or null.
 * @param id The database value.
 * @return A corresponding Type instance, or null.
 */
private static Type byTypeId(int id) {
    switch(id) {
    case Im.TYPE_CUSTOM: return CUSTOM;
    case Im.TYPE_HOME: return HOME;
    case Im.TYPE_OTHER: return OTHER;
    case Im.TYPE_WORK: return WORK;
    }
    return null;
}
 
private void fillFromCursor() {
    data = getString(Im.DATA);
    final String protocolId = getString(Im.PROTOCOL);
    final String customProtocol = getString(Im.CUSTOM_PROTOCOL);
    protocol = getProtocolName(protocolId, customProtocol);
}
 
 类所在包
 类方法
 同包方法