Search in sources :

Example 1 with FriendRecommentVo

use of com.lingtuan.firefly.contact.vo.FriendRecommentVo 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 2 with FriendRecommentVo

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

the class XmppService method parseSystem.

/**
 * Information processing system
 */
private ChatMsg parseSystem(Message msg) {
    try {
        ChatMsg chatmsg = parseBody(msg);
        chatmsg.setMsgType(msg.getMsgtype());
        if (chatmsg.getType() == -1 && Utils.getIMEI(XmppService.this).equals(msg.getTo().split("/")[1])) {
            // Forced offline
            offLinetype = -1;
            Bundle bundle = new Bundle();
            bundle.putString("offlineContent", chatmsg.getContent());
            Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MAIN_OFFLINE_LISTENER, bundle);
            return null;
        }
        if (chatmsg.getType() == 20000 && Utils.getIMEI(XmppService.this).equals(msg.getTo().split("/")[1])) {
            // Anchor force
            // Forced offline
            Bundle bundle = new Bundle();
            bundle.putString("livingofflineContent", chatmsg.getContent());
            Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MAIN_LIVING_OFFLINE_LISTENER, bundle);
            return null;
        }
        if (!checkSystemType(chatmsg.getType())) {
            return null;
        }
        if (chatmsg.getType() == 23) {
            // Friend recommended information
            FriendRecommentVo vo = parseFriendRecommentVo(msg);
            vo.setUnread(1);
            boolean saved = FinalUserDataBase.getInstance().saveFriendsReComment(vo);
            if (saved) {
                Intent intent = new Intent(XmppAction.ACTION_FRIEND_RECOMMENT);
                Bundle bundle = new Bundle();
                bundle.putParcelable(XmppAction.ACTION_FRIEND_RECOMMENT, vo);
                intent.putExtras(bundle);
                Utils.sendBroadcastReceiver(getApplicationContext(), intent, true);
            }
            return null;
        }
        if (chatmsg.getType() == 1) {
            // Passive add buddy Refresh the list
            LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(new Intent(Constants.ACTION_SELECT_CONTACT_REFRESH));
            FinalUserDataBase.getInstance().deleteFriendsRecommentByUid(chatmsg.getUserId());
            return null;
        }
        int type = 0;
        if (chatmsg.getType() > 2 && chatmsg.getType() < 12 || chatmsg.getType() == 21) {
            // invitation
            // Use this field labeled invitation is a group activity
            chatmsg.setGroupMask(!TextUtils.isEmpty(chatmsg.getGroupId()) ? true : false);
            Bundle bundle = new Bundle();
            bundle.putSerializable(XmppAction.ACTION_MESSAGE_ADDINVITE, chatmsg);
            Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MESSAGE_ADDINVITE, bundle);
            type = 1;
        } else if ((chatmsg.getType() > 11 && chatmsg.getType() < 19) || chatmsg.getType() == 22) {
            // Group chat chat system information with unified handling
            return parseGroupChat(msg, true);
        } else if ((chatmsg.getType() > 100 && chatmsg.getType() < 120) || chatmsg.getType() == 1000) {
            // Group system information
            switch(// Group chat window notification
            chatmsg.getType()) {
                case 101:
                case 104:
                    chatmsg.setCreateName(chatmsg.getInviteName());
                    // //As is a group of the Lord or administrator to invite someone else
                    chatmsg.setModifyType(chatmsg.getIs_manager() == 1 ? 1 : 0);
                    break;
                case 102:
                case 103:
                    chatmsg.setCreateName(chatmsg.getBeinviteName());
                    break;
                case 105:
                    break;
                case 115:
                case 116:
                    // As a group of frequency change
                    chatmsg.setModifyType(chatmsg.getLefttimes());
                    break;
                case 108:
                case 109:
                    return parseSuperGroupChat(msg, true);
                case 1000:
                    return parseSuperGroupChat(msg, true);
            }
            type = 3;
            String[] uids = chatmsg.getChatId().split("@");
            if (uids.length > 1) {
                chatmsg.setUserId(chatmsg.getGroupId() + "@" + uids[1]);
            } else {
                chatmsg.setUserId(chatmsg.getGroupId());
            }
            chatmsg.setUsername(chatmsg.getGroupName());
            chatmsg.setUserImage(chatmsg.getGroupImage());
            Bundle bundle = new Bundle();
            bundle.putSerializable(XmppAction.ACTION_MESSAGE_ADDGROUP, chatmsg);
            Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MESSAGE_ADDGROUP, bundle);
        } else if (// Payment message
        chatmsg.getType() > 199 && chatmsg.getType() < 211) {
            type = 4;
            Bundle bundle = new Bundle();
            bundle.putSerializable(XmppAction.ACTION_MESSAGE_ADDMONEY, chatmsg);
            Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MESSAGE_ADDMONEY, bundle);
        } else if (// Single system messages
        chatmsg.getType() == 500) {
            return parseNormalChat(msg, true);
        }
        if (chatmsg.getType() == 0) {
            // Add buddy information to heavy or not deleted!
            String messageid = FinalUserDataBase.getInstance().hasFriendAddMsg(chatmsg.getChatId());
            if (!TextUtils.isEmpty(messageid)) {
                cantAddUnreadCount = true;
                chatmsg.setUnread(0);
                FinalUserDataBase.getInstance().deleteChatEventAddContactByMessageId(messageid);
            }
            Bundle bundle = new Bundle();
            bundle.putSerializable(XmppAction.ACTION_MESSAGE_ADDCONTACT, chatmsg);
            Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MESSAGE_ADDCONTACT, bundle);
        }
        try {
            MySharedPrefs.writeBoolean(NextApplication.mContext, MySharedPrefs.FILE_USER, MySharedPrefs.IS_MASK_MSG + NextApplication.myInfo.getLocalId() + "_" + chatmsg.getChatId(), chatmsg.getGroupMask());
        } catch (Exception e) {
            e.printStackTrace();
        }
        chatmsg.setChatId("system-" + type);
        chatmsg.setSystem(true);
        chatmsg.setHidden(false);
        FinalUserDataBase.getInstance().saveChatEvent(chatmsg);
        chatmsg.setHidden(true);
        FinalUserDataBase.getInstance().saveChatEvent(chatmsg);
        return chatmsg;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : FriendRecommentVo(com.lingtuan.firefly.contact.vo.FriendRecommentVo) Bundle(android.os.Bundle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 3 with FriendRecommentVo

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

the class RecommentContactListAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Holder h;
    final FriendRecommentVo vo = mList.get(position);
    if (convertView == null) {
        h = new Holder();
        convertView = View.inflate(mContext, R.layout.item_msg_contact, null);
        h.avatar = (ImageView) convertView.findViewById(R.id.item_avatar);
        h.content = (TextView) convertView.findViewById(R.id.item_content);
        h.time = (TextView) convertView.findViewById(R.id.item_times);
        h.nickname = (TextView) convertView.findViewById(R.id.item_nickname);
        h.agreeBtn = (TextView) convertView.findViewById(R.id.item_msg_event_agree);
        convertView.setTag(h);
    } else {
        h = (Holder) convertView.getTag();
    }
    String nickname = vo.getUsername();
    String content = mContext.getResources().getString(R.string.contact_friends);
    if (!TextUtils.isEmpty(vo.getThirdName())) {
        content = content.concat(":" + vo.getThirdName());
    }
    h.time.setVisibility(View.GONE);
    NextApplication.displayCircleImage(h.avatar, vo.getThumb());
    h.nickname.setText(nickname);
    h.content.setText(content);
    h.agreeBtn.setVisibility(View.VISIBLE);
    if (vo.isAgree()) {
        h.agreeBtn.setText(R.string.added);
        h.agreeBtn.setTextColor(mContext.getResources().getColor(R.color.textColorHint));
        h.agreeBtn.setEnabled(false);
        h.agreeBtn.setBackgroundDrawable(null);
    } else {
        h.agreeBtn.setEnabled(true);
        h.agreeBtn.setText(R.string.add_friends);
        h.agreeBtn.setTextColor(mContext.getResources().getColor(R.color.textColor));
        h.agreeBtn.setBackgroundResource(R.drawable.selector_round_black_5);
    }
    h.agreeBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            requestAgree(vo);
        }
    });
    return convertView;
}
Also used : FriendRecommentVo(com.lingtuan.firefly.contact.vo.FriendRecommentVo) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 4 with FriendRecommentVo

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

the class FinalUserDataBase method getFriendsRecomment.

/**
 * For reference information
 *
 * @return
 */
public List<FriendRecommentVo> getFriendsRecomment() {
    List<FriendRecommentVo> mList = new ArrayList<FriendRecommentVo>();
    if (null == db) {
        return mList;
    }
    String sql = "select * from " + TableField.TABLE_FRIENDS_RECOMMENT + " order by " + TableField._ID + " desc ";
    Cursor cursor = db.rawQuery(sql, null);
    FriendRecommentVo msg;
    while (cursor.moveToNext()) {
        msg = new FriendRecommentVo();
        msg.setMsgId(cursor.getString(cursor.getColumnIndex(TableField._MSGID)));
        msg.setFriendId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_THIRDID)));
        msg.setUid(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
        msg.setUsername(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
        msg.setPic(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_PIC)));
        msg.setThumb(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_THUMB)));
        msg.setType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_TYPE)));
        msg.setTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_CHAT_MSGTIME)));
        msg.setUnread(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_UNREAD)));
        msg.setThirdName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_THIRDNAME)));
        UserBaseVo baseVo = FinalUserDataBase.getInstance().getUserBaseVoByUid(msg.getUid());
        if (baseVo == null) {
            // 不是好友
            msg.setAgree(false);
        } else {
            msg.setAgree(true);
        }
        try {
            if (!TextUtils.isEmpty(msg.getThirdName())) {
                if (msg.getThirdName().endsWith(")") && msg.getThirdName().contains("(")) {
                    msg.setThirdName(msg.getThirdName().substring(0, msg.getThirdName().lastIndexOf("(")));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        mList.add(msg);
    }
    cursor.close();
    return mList;
}
Also used : FriendRecommentVo(com.lingtuan.firefly.contact.vo.FriendRecommentVo) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Aggregations

FriendRecommentVo (com.lingtuan.firefly.contact.vo.FriendRecommentVo)4 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 Bundle (android.os.Bundle)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 PhoneContactVo (com.lingtuan.firefly.contact.vo.PhoneContactVo)1 ChatMsg (com.lingtuan.firefly.vo.ChatMsg)1 UserBaseVo (com.lingtuan.firefly.vo.UserBaseVo)1 ArrayList (java.util.ArrayList)1