Search in sources :

Example 41 with ChatMsg

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

the class ContactSelectedUI method createImageChatMsg.

/**
 * Create photo chat entity class
 */
private ChatMsg createImageChatMsg(String uid, String content, String uName, String avatarUrl, String cover, boolean isGroup, boolean isSend) {
    ChatMsg chatMsg = new ChatMsg();
    chatMsg.setType(1);
    // 
    chatMsg.setContent(content);
    chatMsg.setLocalUrl(content);
    chatMsg.setCover(cover);
    chatMsg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
    String jid = uid + "@" + XmppUtils.SERVER_NAME;
    if (isGroup) {
        jid = uid.replace("group-", "") + "@group." + XmppUtils.SERVER_NAME;
    }
    org.jivesoftware.smack.packet.Message msg = new org.jivesoftware.smack.packet.Message(jid, org.jivesoftware.smack.packet.Message.Type.chat);
    chatMsg.setMessageId(msg.getPacketID());
    if (isGroup) {
        // 
        msg.setMsgtype(MsgType.groupchat);
        chatMsg.setChatId(uid);
        chatMsg.setGroup(isGroup);
        chatMsg.setSource(NextApplication.mContext.getString(R.string.app_name));
        chatMsg.setUserfrom(getString(R.string.app_name));
        chatMsg.setUsersource(XmppUtils.SERVER_NAME);
        msg.setBody(chatMsg.toGroupChatJsonObject());
    } else {
        chatMsg.setSource(getString(R.string.app_name));
        msg.setBody(chatMsg.toChatJsonObject());
    }
    chatMsg.setMsgTime(System.currentTimeMillis() / 1000);
    if (isSend) {
        chatMsg.setSend(2);
    }
    FinalUserDataBase.getInstance().saveChatMsg(chatMsg, uid, uName, avatarUrl);
    chatMsg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
    if (isSend) {
        Bundle bundle = new Bundle();
        bundle.putInt("type", 2);
        bundle.putString("uid", uid);
        bundle.putString("username", uName);
        bundle.putString("avatarurl", avatarUrl);
        bundle.putSerializable("chatmsg", chatMsg);
        Utils.intentService(this, LoadDataService.class, LoadDataService.ACTION_FILE_UPLOAD_CHAT, LoadDataService.ACTION_FILE_UPLOAD_CHAT, bundle);
    }
    return chatMsg;
}
Also used : Message(android.os.Message) Bundle(android.os.Bundle) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 42 with ChatMsg

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

the class DiscussGroupMemberListUI method inviteOthersChatMsg.

private void inviteOthersChatMsg(final String name) {
    StringBuilder sb = new StringBuilder();
    int index = 1;
    for (UserBaseVo vo : data) {
        if (// Most need four pictures
        index > 4) {
            break;
        }
        sb.append(vo.getThumb()).append("___").append(vo.getGender()).append("#");
        index++;
    }
    sb.deleteCharAt(sb.lastIndexOf("#"));
    String url = sb.toString();
    ChatMsg chatmsg = new ChatMsg();
    chatmsg.setChatId("group-" + cid);
    chatmsg.setGroupName(name);
    chatmsg.setGroup(true);
    chatmsg.setType(13);
    chatmsg.setSend(1);
    chatmsg.setContent(getString(R.string.discuss_group_invite_others, name));
    chatmsg.setMsgTime(System.currentTimeMillis() / 1000);
    chatmsg.setMessageId(UUID.randomUUID().toString());
    chatmsg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
    Bundle bundle = new Bundle();
    bundle.putSerializable(XmppAction.ACTION_MESSAGE_LISTENER, chatmsg);
    Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MESSAGE_LISTENER, bundle);
    FinalUserDataBase.getInstance().saveChatMsg(chatmsg, chatmsg.getChatId(), name, url, false);
}
Also used : Bundle(android.os.Bundle) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 43 with ChatMsg

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

the class DiscussGroupSettingUI method removeMemberChatMsg.

/**
 * Forge a delete members of the group chat message
 */
private void removeMemberChatMsg(final String name) {
    StringBuilder sb = new StringBuilder();
    int index = 1;
    for (UserBaseVo vo : data) {
        if (// Most need four pictures
        index > 4) {
            break;
        }
        sb.append(vo.getThumb()).append("___").append(vo.getGender()).append("#");
        index++;
    }
    sb.deleteCharAt(sb.lastIndexOf("#"));
    String url = sb.toString();
    ChatMsg chatmsg = new ChatMsg();
    chatmsg.setChatId("group-" + cid);
    chatmsg.setGroupName(nameEdit.getText().toString());
    chatmsg.setGroup(true);
    chatmsg.setType(14);
    chatmsg.setSend(1);
    chatmsg.setContent(getString(R.string.discuss_group_remove_other, name));
    chatmsg.setMsgTime(System.currentTimeMillis() / 1000);
    chatmsg.setMessageId(UUID.randomUUID().toString());
    chatmsg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
    Bundle bundle = new Bundle();
    bundle.putSerializable(XmppAction.ACTION_MESSAGE_LISTENER, chatmsg);
    Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MESSAGE_LISTENER, bundle);
    FinalUserDataBase.getInstance().saveChatMsg(chatmsg, chatmsg.getChatId(), nameEdit.getText().toString(), url, false);
}
Also used : Bundle(android.os.Bundle) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 44 with ChatMsg

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

the class ContactAddAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Holder h;
    final ChatMsg msg = 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 url = "";
    String nickname = "";
    String content = "";
    nickname = msg.getUsername();
    url = msg.getUserImage();
    if (!TextUtils.isEmpty(msg.getContent())) {
        content = msg.getContent();
        Utils.setLoginTime(mContext, h.time, msg.getMsgTime());
    } else if (!TextUtils.isEmpty(msg.getShareFriendName())) {
        content = mContext.getResources().getString(R.string.contact_add_content_share, msg.getShareFriendName());
        h.time.setText(mContext.getString(R.string.friend_hope_add));
    } else {
        content = mContext.getResources().getString(R.string.contact_add_content, msg.getUsername());
        Utils.setLoginTime(mContext, h.time, msg.getMsgTime());
    }
    NextApplication.displayCircleImage(h.avatar, url);
    h.nickname.setText(nickname);
    h.content.setText(content);
    h.agreeBtn.setVisibility(View.VISIBLE);
    if (msg.isAgree()) {
        h.agreeBtn.setText(R.string.agreeed);
        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.agree);
        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) {
            h.agreeBtn.setEnabled(false);
            requestAgree(h, msg);
        }
    });
    return convertView;
}
Also used : ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 45 with ChatMsg

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

the class MsgTransAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Holder h;
    final ChatMsg chatMsg = mList.get(position);
    if (convertView == null) {
        h = new Holder();
        convertView = View.inflate(mContext, R.layout.item_msg_trans, null);
        h.transNotify = (TextView) convertView.findViewById(R.id.transNotify);
        h.transTime = (TextView) convertView.findViewById(R.id.transTime);
        h.transFromAddress = (TextView) convertView.findViewById(R.id.transFromAddress);
        convertView.setTag(h);
    } else {
        h = (Holder) convertView.getTag();
    }
    Utils.setLoginTime(mContext, h.transTime, chatMsg.getMsgTime());
    if (chatMsg.getNoticeType() == 0) {
        if (TextUtils.equals("0", chatMsg.getMode())) {
            // eth
            if (chatMsg.getInviteType() == 0) {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_msg_eth, chatMsg.getMoney()));
            } else {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_msg_eth_failed, chatMsg.getMoney()));
            }
        } else if (TextUtils.equals("1", chatMsg.getMode())) {
            if (chatMsg.getInviteType() == 0) {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_msg_smt, chatMsg.getMoney()));
            } else {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_msg_smt_failed, chatMsg.getMoney()));
            }
        } else if (TextUtils.equals("2", chatMsg.getMode())) {
            if (chatMsg.getInviteType() == 0) {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_msg_mesh, chatMsg.getMoney()));
            } else {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_msg_mesh_failed, chatMsg.getMoney()));
            }
        }
        h.transFromAddress.setText(mContext.getString(R.string.wallet_trans_to, chatMsg.getToAddress()));
    } else {
        if (TextUtils.equals("0", chatMsg.getMode())) {
            // eth
            if (chatMsg.getInviteType() == 0) {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_collect_eth, chatMsg.getMoney()));
            } else {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_collect_eth_failed, chatMsg.getMoney()));
            }
        } else if (TextUtils.equals("1", chatMsg.getMode())) {
            if (chatMsg.getInviteType() == 0) {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_collect_smt, chatMsg.getMoney()));
            } else {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_collect_smt_failed, chatMsg.getMoney()));
            }
        } else if (TextUtils.equals("2", chatMsg.getMode())) {
            if (chatMsg.getInviteType() == 0) {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_collect_mesh, chatMsg.getMoney()));
            } else {
                h.transNotify.setText(mContext.getString(R.string.wallet_trans_collect_mesh_failed, chatMsg.getMoney()));
            }
        }
        h.transFromAddress.setText(mContext.getString(R.string.wallet_trans_from, chatMsg.getFromAddress()));
    }
    return convertView;
}
Also used : ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Aggregations

ChatMsg (com.lingtuan.firefly.vo.ChatMsg)61 Bundle (android.os.Bundle)17 Intent (android.content.Intent)12 ArrayList (java.util.ArrayList)11 UserBaseVo (com.lingtuan.firefly.vo.UserBaseVo)9 Cursor (android.database.Cursor)8 SuppressLint (android.annotation.SuppressLint)6 WifiPeopleVO (com.lingtuan.firefly.offline.vo.WifiPeopleVO)5 View (android.view.View)4 ImageView (android.widget.ImageView)4 GroupMemberAvatarVo (com.lingtuan.firefly.contact.vo.GroupMemberAvatarVo)4 PendingIntent (android.app.PendingIntent)3 TextView (android.widget.TextView)3 MyDialogFragment (com.lingtuan.firefly.util.MyDialogFragment)3 LoginThread (com.lingtuan.firefly.xmpp.LoginThread)3 File (java.io.File)3 JSONObject (org.json.JSONObject)3 Bitmap (android.graphics.Bitmap)2 Message (android.os.Message)2 Editable (android.text.Editable)2