Search in sources :

Example 1 with PhoneContactVo

use of com.lingtuan.firefly.contact.vo.PhoneContactVo in project SmartMesh_Android by SmartMeshFoundation.

the class FinalUserDataBase method getPhoneContactList.

/**
 * Get the address book information
 *
 * @param type 1. Mobile phone address book, 2. Sina weibo friends, 3. Tencent weibo friends
 * @return
 */
public List<PhoneContactVo> getPhoneContactList(int type) {
    List<PhoneContactVo> mList = new ArrayList<PhoneContactVo>();
    if (db == null) {
        return mList;
    }
    String sql = "select * from " + TableField.TABLE_CONTACT + " where " + TableField.FIELD_CHAT_TYPE + "=? " + " order by " + TableField.FIELD_FRIEND_UNAME;
    Cursor cursor = db.rawQuery(sql, new String[] { String.valueOf(type) });
    PhoneContactVo vo;
    while (cursor.moveToNext()) {
        vo = new PhoneContactVo();
        vo.setId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_THIRDID)));
        vo.setName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
        vo.setNote(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_NOTE)));
        vo.setRelation(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_RELATION)));
        vo.setUid(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
        vo.setType(type);
        mList.add(vo);
    }
    cursor.close();
    return mList;
}
Also used : PhoneContactVo(com.lingtuan.firefly.contact.vo.PhoneContactVo) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 2 with PhoneContactVo

use of com.lingtuan.firefly.contact.vo.PhoneContactVo in project SmartMesh_Android by SmartMeshFoundation.

the class LoadDataService method getPeopleInPhone.

/**
 *The address book query
 */
private List<String> getPeopleInPhone() {
    String select;
    int version = android.os.Build.VERSION.SDK_INT;
    if (version > 10) {
        // More than 2.3 version of the system
        select = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))";
    } else {
        // Less than or equal to 2.3
        select = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))";
    }
    // 获取手机联系人
    Cursor cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, select, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
    List<String> mList = new ArrayList<>();
    StringBuilder sb = new StringBuilder();
    while (cursor != null && cursor.moveToNext()) {
        // people name
        int indexPeopleName = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
        // phone number
        int indexPhoneNum = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
        String name = cursor.getString(indexPeopleName);
        String number = cursor.getString(indexPhoneNum);
        if (!TextUtils.isEmpty(number)) {
            // Some garbage data filtering
            number = number.replace("-", "");
            number = number.replace("*", "");
            number = number.replace("+86", "").trim();
            number = number.replace(" ", "").trim();
            if (!number.startsWith("400") && number.length() >= 11) {
                // 
                sb.append(number);
                sb.append(",");
                mList.add(number);
            }
        }
        PhoneContactVo vo = new PhoneContactVo();
        vo.setName(name);
        vo.setId(number);
        vo.setType(1);
        FinalUserDataBase.getInstance().savePhoneContact(vo, false);
    }
    if (!TextUtils.isEmpty(sb.toString())) {
        sb.deleteCharAt(sb.lastIndexOf(","));
    }
    if (cursor != null && !cursor.isClosed()) {
        cursor.close();
        cursor = null;
    }
    typeList = sb.toString();
    return mList;
}
Also used : PhoneContactVo(com.lingtuan.firefly.contact.vo.PhoneContactVo) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) LatLonPoint(com.amap.api.services.core.LatLonPoint)

Example 3 with PhoneContactVo

use of com.lingtuan.firefly.contact.vo.PhoneContactVo in project SmartMesh_Android by SmartMeshFoundation.

the class XmppService method parseFriendRecommentVo.

/**
 * Parsing friend recommendation information
 */
private FriendRecommentVo parseFriendRecommentVo(Message msg) {
    FriendRecommentVo vo = new FriendRecommentVo();
    vo.parseXmpp(msg.getBody());
    vo.setMsgId(msg.getPacketID());
    if (vo.getType() == 0) {
        // The address book friends
        PhoneContactVo cVo = FinalUserDataBase.getInstance().getPhoneContactById(vo.getFriendId(), 1);
        if (cVo != null) {
            vo.setThirdName(cVo.getName());
        }
    }
    return vo;
}
Also used : FriendRecommentVo(com.lingtuan.firefly.contact.vo.FriendRecommentVo) PhoneContactVo(com.lingtuan.firefly.contact.vo.PhoneContactVo)

Example 4 with PhoneContactVo

use of com.lingtuan.firefly.contact.vo.PhoneContactVo in project SmartMesh_Android by SmartMeshFoundation.

the class AddContactFriendsAdapter method getChildView.

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
    HolderChild h;
    if (convertView == null) {
        h = new HolderChild();
        convertView = View.inflate(mContext, R.layout.contact_add_child_item, null);
        h.nickName = (TextView) convertView.findViewById(R.id.nearby_nickname);
        h.addFriend = (TextView) convertView.findViewById(R.id.nearby_time);
        convertView.setTag(h);
    } else {
        h = (HolderChild) convertView.getTag();
    }
    Resources resources = mContext.getResources();
    final PhoneContactVo vo = mGroupInfoList.get(groupPosition).getContactList().get(childPosition);
    h.nickName.setText(vo.getShowName());
    if (vo.getRelation() == 0) {
        // Can invite
        h.addFriend.setText(resources.getString(R.string.invite));
        h.addFriend.setEnabled(true);
        h.addFriend.setTextColor(resources.getColor(R.color.textColor));
        h.addFriend.setBackgroundResource(R.drawable.selector_round_black_5);
    } else if (vo.getRelation() == 1) {
        // You can add
        h.addFriend.setText(resources.getString(R.string.add_friends));
        h.addFriend.setEnabled(true);
        h.addFriend.setTextColor(resources.getColor(R.color.textColor));
        h.addFriend.setBackgroundResource(R.drawable.selector_round_black_5);
    } else {
        // Has been added
        h.addFriend.setText(resources.getString(R.string.contact_already_friends));
        h.addFriend.setEnabled(false);
        h.addFriend.setTextColor(resources.getColor(R.color.textColorHint));
        h.addFriend.setBackgroundDrawable(null);
    }
    h.addFriend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.addContactCallback(vo.getRelation() == 1 ? vo.getUid() + "" : vo.getId(), vo.getRelation() + "", addType, vo.getName());
            }
        }
    });
    return convertView;
}
Also used : PhoneContactVo(com.lingtuan.firefly.contact.vo.PhoneContactVo) OnClickListener(android.view.View.OnClickListener) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 5 with PhoneContactVo

use of com.lingtuan.firefly.contact.vo.PhoneContactVo in project SmartMesh_Android by SmartMeshFoundation.

the class FinalUserDataBase method getPhoneContactById.

/**
 * for a single recommendation
 *Unique identifier * @ param id friends phone number, openI
 * @param type
 * @return
 */
public PhoneContactVo getPhoneContactById(String id, int type) {
    String sql = "select * from " + TableField.TABLE_CONTACT + " where " + TableField.FIELD_CHAT_THIRDID + "=? and " + TableField.FIELD_CHAT_TYPE + "=?";
    Cursor cursor = db.rawQuery(sql, new String[] { id, String.valueOf(type) });
    PhoneContactVo vo = null;
    if (cursor.moveToNext()) {
        vo = new PhoneContactVo();
        vo.setId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_THIRDID)));
        vo.setName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
        vo.setNote(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_NOTE)));
        vo.setRelation(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_RELATION)));
        vo.setUid(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
        vo.setType(type);
    }
    cursor.close();
    return vo;
}
Also used : PhoneContactVo(com.lingtuan.firefly.contact.vo.PhoneContactVo) Cursor(android.database.Cursor)

Aggregations

PhoneContactVo (com.lingtuan.firefly.contact.vo.PhoneContactVo)6 Cursor (android.database.Cursor)4 ArrayList (java.util.ArrayList)3 Resources (android.content.res.Resources)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 LatLonPoint (com.amap.api.services.core.LatLonPoint)1 FriendRecommentVo (com.lingtuan.firefly.contact.vo.FriendRecommentVo)1 PhoneContactGroupVo (com.lingtuan.firefly.contact.vo.PhoneContactGroupVo)1