Search in sources :

Example 26 with ChatMsg

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

the class LoadDataService method removeSendmsgList.

/*Remove the messages sent, send after the failure or success*/
private void removeSendmsgList(ChatMsg sendedMsg) {
    for (int i = 0; i < sendingMsgList.size(); i++) {
        ChatMsg msg = sendingMsgList.get(i);
        if (sendedMsg.getChatId().equals(msg.getChatId()) && sendedMsg.getType() == msg.getType() && sendedMsg.getMessageId().equals(msg.getMessageId())) {
            sendingMsgList.remove(i);
            i--;
        }
    }
}
Also used : LatLonPoint(com.amap.api.services.core.LatLonPoint) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 27 with ChatMsg

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

the class XmppService method parseRoomChat.

/**
 * Everyone chat room
 */
private ChatMsg parseRoomChat(Message msg) {
    if (!TextUtils.isEmpty(msg.getBody())) {
        try {
            String content = null;
            ChatMsg chatmsg = parseBody(msg);
            chatmsg.setSend(1);
            chatmsg.setMsgType(msg.getMsgtype());
            chatmsg.setChatId("everyone");
            {
                if (!checkChatType(chatmsg.getType())) {
                    chatmsg.setType(50000);
                }
                switch(chatmsg.getType()) {
                    case // Share the news
                    13:
                        chatmsg.setType(103);
                        content = chatmsg.getContent();
                        break;
                    case // Not compatible with high version of the news
                    50000:
                        chatmsg.setContent(chatmsg.getMsgName());
                        break;
                }
            }
            final String avatarUrl = chatmsg.getUserImage();
            String uName = chatmsg.getUsername();
            chatmsg.setGroupName(getString(R.string.everyone));
            FinalUserDataBase.getInstance().saveChatMsg(chatmsg, chatmsg.getChatId(), chatmsg.getGroupName(), null);
            chatmsg.setUsername(uName);
            chatmsg.setUserImage(avatarUrl);
            if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                chatmsg.setContent(content);
            }
            Bundle bundle = new Bundle();
            bundle.putSerializable(XmppAction.ACTION_MESSAGE_LISTENER, chatmsg);
            Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MESSAGE_LISTENER, bundle);
            if (chatmsg.getType() == 2) {
                // Download the audio files
                Bundle downloadBundle = new Bundle();
                downloadBundle.putString("uid", chatmsg.getChatId());
                downloadBundle.putString("username", chatmsg.getUsername());
                downloadBundle.putString("avatarurl", chatmsg.getUserImage());
                downloadBundle.putSerializable("chatmsg", chatmsg);
                Utils.intentService(getApplicationContext(), LoadDataService.class, LoadDataService.ACTION_FILE_DOWNLOAD, LoadDataService.ACTION_FILE_DOWNLOAD, downloadBundle);
            }
            if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                chatmsg.setContent(chatmsg.getShareTitle());
            }
            return chatmsg;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return null;
}
Also used : Bundle(android.os.Bundle) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 28 with ChatMsg

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

the class XmppService method parseOfflineBody.

private ChatMsg parseOfflineBody(ChatMsg msg, JSONObject obj, int unreadcount, MsgType type) throws Exception {
    ChatMsg chatmsg = new ChatMsg().parse(obj, msg, type);
    chatmsg.setUnread(unreadcount);
    return chatmsg;
}
Also used : ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 29 with ChatMsg

use of com.lingtuan.firefly.vo.ChatMsg 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 30 with ChatMsg

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

the class XmppService method parseOfflineMsgList.

private synchronized void parseOfflineMsgList(ChatMsg msgs, MsgType type) {
    ArrayList<ChatMsg> offlineList = new ArrayList<>();
    if (msgs != null && msgs.getOfflinmsgList() != null) {
        // Offline message set
        JSONArray offlinemsgList = new JSONArray();
        for (int index = 0; index < msgs.getOfflinmsgList().length(); index++) {
            // This step is to throw out temporarily unable to parse messages and repeat
            try {
                JSONObject obj = (JSONObject) msgs.getOfflinmsgList().get(index);
                int msgtype = obj.optInt("type");
                boolean isMsgExit = FinalUserDataBase.getInstance().checkMsgExist(obj.optString("msgid"), type, msgtype);
                if (isMsgExit) {
                    // To repeat
                    continue;
                }
                if (type == MsgType.super_groupchat) {
                    msgtype = msgtype - 1000;
                }
                if (msgtype == 21) {
                    // Group broadcast messages don't do offline message processing, direct abandoned
                    continue;
                }
                offlinemsgList.put(obj);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        // Manually start the transaction
        FinalUserDataBase.getInstance().beginTransaction();
        int totalCount = 0;
        for (int index = 0; index < offlinemsgList.length(); index++) {
            JSONObject object = offlinemsgList.optJSONObject(index);
            if (type == MsgType.everyone) {
                // normalChat
                try {
                    String content = null;
                    ChatMsg chatmsg = parseOfflineBody(msgs, object, index == offlinemsgList.length() - 1 ? offlinemsgList.length() : 0, type);
                    chatmsg.setMsgType(msgs.getMsgType());
                    if (!checkChatType(chatmsg.getType())) {
                        chatmsg.setType(50000);
                    }
                    switch(chatmsg.getType()) {
                        case // Share the news
                        13:
                            chatmsg.setType(103);
                            content = chatmsg.getContent();
                            break;
                        case // Not compatible with high version of the news
                        50000:
                            chatmsg.setContent(chatmsg.getMsgName());
                            break;
                    }
                    FinalUserDataBase.getInstance().saveChatMsgNew(chatmsg, chatmsg.getUserId(), chatmsg.getUsername(), chatmsg.getUserImage(), index == offlinemsgList.length() - 1);
                    if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                        chatmsg.setContent(content);
                    }
                    offlineList.add(chatmsg);
                    if (index == offlinemsgList.length() - 1) {
                        // Collection of traverse after send to unity
                        Intent intent = new Intent(XmppAction.ACTION_OFFLINE_MESSAGE_LIST_LISTENER);
                        intent.putExtra("array", offlineList);
                        Utils.intentAction(getApplicationContext(), intent);
                    }
                    if (chatmsg.getType() == 2) {
                        // Download the audio files
                        Bundle downloadBundle = new Bundle();
                        downloadBundle.putString("uid", chatmsg.getChatId());
                        downloadBundle.putString("username", chatmsg.getUsername());
                        downloadBundle.putString("avatarurl", chatmsg.getUserImage());
                        downloadBundle.putSerializable("chatmsg", chatmsg);
                        Utils.intentService(getApplicationContext(), LoadDataService.class, LoadDataService.ACTION_FILE_DOWNLOAD, LoadDataService.ACTION_FILE_DOWNLOAD, downloadBundle);
                    }
                    if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                        chatmsg.setContent(chatmsg.getShareTitle());
                    }
                    totalCount++;
                    if (index == offlinemsgList.length() - 1) {
                        // Collection of traverse after send to unity
                        Intent intent = new Intent(XmppAction.ACTION_OFFLINE_MESSAGE_LIST_EVENT_LISTENER);
                        intent.putExtra("chat", chatmsg);
                        intent.putExtra("totalCount", totalCount);
                        Utils.intentAction(getApplicationContext(), intent);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (type == MsgType.normalchat) {
                // normalChat
                try {
                    String content = null;
                    ChatMsg chatmsg = parseOfflineBody(msgs, object, index == offlinemsgList.length() - 1 ? offlinemsgList.length() : 0, type);
                    chatmsg.setMsgType(msgs.getMsgType());
                    if (!checkChatType(chatmsg.getType())) {
                        chatmsg.setType(50000);
                    }
                    switch(chatmsg.getType()) {
                        case // Share the news
                        13:
                            chatmsg.setType(103);
                            content = chatmsg.getContent();
                            break;
                        case // file
                        19:
                            chatmsg.setInviteType(4);
                            chatmsg.setType(1009);
                            break;
                        case // Not compatible with high version of the news
                        50000:
                            chatmsg.setContent(chatmsg.getMsgName());
                            break;
                    }
                    FinalUserDataBase.getInstance().saveChatMsgNew(chatmsg, chatmsg.getUserId(), chatmsg.getUsername(), chatmsg.getUserImage(), index == offlinemsgList.length() - 1);
                    if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                        chatmsg.setContent(content);
                    }
                    offlineList.add(chatmsg);
                    if (index == offlinemsgList.length() - 1) {
                        // Collection of traverse after send to unity
                        Intent intent = new Intent(XmppAction.ACTION_OFFLINE_MESSAGE_LIST_LISTENER);
                        intent.putExtra("array", offlineList);
                        Utils.intentAction(getApplicationContext(), intent);
                    }
                    if (chatmsg.getType() == 2) {
                        // Download the audio files
                        Bundle downloadBundle = new Bundle();
                        downloadBundle.putString("uid", chatmsg.getChatId());
                        downloadBundle.putString("username", chatmsg.getUsername());
                        downloadBundle.putString("avatarurl", chatmsg.getUserImage());
                        downloadBundle.putSerializable("chatmsg", chatmsg);
                        Utils.intentService(getApplicationContext(), LoadDataService.class, LoadDataService.ACTION_FILE_DOWNLOAD, LoadDataService.ACTION_FILE_DOWNLOAD, downloadBundle);
                    }
                    if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                        chatmsg.setContent(chatmsg.getShareTitle());
                    }
                    if (chatmsg.getGroupMask() && !TextUtils.equals("system-0", chatmsg.getChatId()) && !TextUtils.equals("system-1", chatmsg.getChatId()) && !TextUtils.equals("system-3", chatmsg.getChatId()) && !TextUtils.equals("system-4", chatmsg.getChatId())) {
                    // 屏蔽的信息不与管理
                    } else if ("system-2".equals(chatmsg.getChatId())) {
                    } else {
                        totalCount++;
                    }
                    if (index == offlinemsgList.length() - 1) {
                        // Collection of traverse after send to unity
                        Intent intent = new Intent(XmppAction.ACTION_OFFLINE_MESSAGE_LIST_EVENT_LISTENER);
                        intent.putExtra("chat", chatmsg);
                        intent.putExtra("totalCount", totalCount);
                        Utils.intentAction(getApplicationContext(), intent);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (type == MsgType.groupchat) {
                // groupchat
                try {
                    String content = null;
                    ChatMsg chatmsg = parseOfflineBody(msgs, object, index == offlinemsgList.length() - 1 ? offlinemsgList.length() : 0, type);
                    chatmsg.setMsgType(msgs.getMsgType());
                    String[] uids = chatmsg.getChatId().split("@");
                    chatmsg.setChatId("group-" + chatmsg.getGroupId());
                    if (// Not from news about your users
                    uids.length > 1) {
                        chatmsg.setChatId(chatmsg.getChatId() + "@" + uids[1]);
                    }
                    chatmsg.setGroup(true);
                    if (!checkChatType(chatmsg.getType())) {
                        chatmsg.setType(50000);
                    }
                    switch(chatmsg.getType()) {
                        case // Share the news
                        13:
                            chatmsg.setType(103);
                            content = chatmsg.getContent();
                            break;
                        case // file
                        19:
                            chatmsg.setInviteType(4);
                            chatmsg.setType(1009);
                            break;
                        case // Not compatible with high version of the news
                        50000:
                            chatmsg.setContent(chatmsg.getMsgName());
                            break;
                    }
                    StringBuilder url = new StringBuilder();
                    if (chatmsg.getMemberAvatarList() != null) {
                        for (GroupMemberAvatarVo vo : chatmsg.getMemberAvatarList()) {
                            url.append(vo.getImage()).append("___").append(vo.getGender()).append("#");
                        }
                        url.deleteCharAt(url.lastIndexOf("#"));
                    }
                    final String avatarUrl = chatmsg.getUserImage();
                    String uName = chatmsg.getUsername();
                    FinalUserDataBase.getInstance().saveChatMsgNew(chatmsg, chatmsg.getChatId(), chatmsg.getGroupName(), url.toString(), index == offlinemsgList.length() - 1 ? true : false);
                    chatmsg.setUsername(uName);
                    chatmsg.setUserImage(avatarUrl);
                    if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                        chatmsg.setContent(content);
                    }
                    offlineList.add(chatmsg);
                    if (// Collection of traverse after send to unity
                    index == offlinemsgList.length() - 1) {
                        Intent intent = new Intent(XmppAction.ACTION_OFFLINE_MESSAGE_LIST_LISTENER);
                        intent.putExtra("array", offlineList);
                        Utils.intentAction(getApplicationContext(), intent);
                    }
                    if (chatmsg.getType() == 2) {
                        // Download the audio files
                        Bundle downloadBundle = new Bundle();
                        downloadBundle.putString("uid", chatmsg.getChatId());
                        downloadBundle.putString("username", chatmsg.getUsername());
                        downloadBundle.putString("avatarurl", chatmsg.getUserImage());
                        downloadBundle.putSerializable("chatmsg", chatmsg);
                        Utils.intentService(getApplicationContext(), LoadDataService.class, LoadDataService.ACTION_FILE_DOWNLOAD, LoadDataService.ACTION_FILE_DOWNLOAD, downloadBundle);
                    }
                    chatmsg.setUserImage(url.toString());
                    if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                        chatmsg.setContent(chatmsg.getShareTitle());
                    }
                    if (chatmsg.getGroupMask() && !TextUtils.equals("system-0", chatmsg.getChatId()) && !TextUtils.equals("system-1", chatmsg.getChatId()) && !TextUtils.equals("system-3", chatmsg.getChatId()) && !TextUtils.equals("system-4", chatmsg.getChatId())) {
                    // 屏蔽的信息不与管理
                    } else if ("system-2".equals(chatmsg.getChatId())) {
                    } else {
                        totalCount++;
                    }
                    if (// Collection of traverse after send to unity
                    index == offlinemsgList.length() - 1) {
                        Intent intent = new Intent(XmppAction.ACTION_OFFLINE_MESSAGE_LIST_EVENT_LISTENER);
                        intent.putExtra("chat", chatmsg);
                        intent.putExtra("totalCount", totalCount);
                        Utils.intentAction(getApplicationContext(), intent);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else if (type == MsgType.super_groupchat) {
                // supergroupvchat
                try {
                    String content = null;
                    ChatMsg chatmsg = parseOfflineBody(msgs, object, index == offlinemsgList.length() - 1 ? offlinemsgList.length() : 0, type);
                    chatmsg.setMsgType(msgs.getMsgType());
                    // Group on the basis of information type as the original+1000
                    chatmsg.setType(chatmsg.getType() - 1000);
                    String[] uids = chatmsg.getChatId().split("@");
                    chatmsg.setChatId("superGroup-" + chatmsg.getGroupId());
                    if (uids.length > 1) {
                        chatmsg.setChatId(chatmsg.getChatId() + "@" + uids[1]);
                    }
                    chatmsg.setGroup(true);
                    if (!checkChatType(chatmsg.getType())) {
                        chatmsg.setType(50000);
                    }
                    switch(chatmsg.getType()) {
                        case // Share the news
                        13:
                            if (!TextUtils.isEmpty(chatmsg.getUsersource()) && !chatmsg.getUsersource().equals(XmppUtils.SERVER_NAME) && !TextUtils.isEmpty(chatmsg.getShareUrl()) && (chatmsg.getShareUrl().contains("/vodInfo.html") || (chatmsg.getShareUrl().contains("/share_vod.html"))) && !chatmsg.getShareUrl().contains(Constants.APP_URL_FLAG)) {
                                chatmsg.setType(50002);
                            } else {
                                chatmsg.setType(103);
                                content = chatmsg.getContent();
                            }
                            break;
                        case // file
                        19:
                            chatmsg.setInviteType(4);
                            chatmsg.setType(1009);
                            break;
                        case // Not compatible with high version of the news
                        50000:
                            chatmsg.setContent(chatmsg.getMsgName());
                            break;
                    }
                    final String avatarUrl = chatmsg.getUserImage();
                    String uName = chatmsg.getUsername();
                    FinalUserDataBase.getInstance().saveChatMsgNew(chatmsg, chatmsg.getChatId(), chatmsg.getGroupName(), chatmsg.getGroupImage(), index == offlinemsgList.length() - 1 ? true : false);
                    chatmsg.setUsername(uName);
                    chatmsg.setUserImage(avatarUrl);
                    if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                        chatmsg.setContent(content);
                    }
                    offlineList.add(chatmsg);
                    if (// Collection of traverse after send to unity
                    index == offlinemsgList.length() - 1) {
                        Intent intent = new Intent(XmppAction.ACTION_OFFLINE_MESSAGE_LIST_LISTENER);
                        intent.putExtra("array", offlineList);
                        Utils.intentAction(getApplicationContext(), intent);
                    }
                    if (chatmsg.getType() == 2) {
                        // Download the audio files
                        Bundle downloadBundle = new Bundle();
                        downloadBundle.putString("uid", chatmsg.getChatId());
                        downloadBundle.putString("username", chatmsg.getUsername());
                        downloadBundle.putString("avatarurl", chatmsg.getUserImage());
                        downloadBundle.putSerializable("chatmsg", chatmsg);
                        Utils.intentService(getApplicationContext(), LoadDataService.class, LoadDataService.ACTION_FILE_DOWNLOAD, LoadDataService.ACTION_FILE_DOWNLOAD, downloadBundle);
                    }
                    if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
                        chatmsg.setContent(chatmsg.getShareTitle());
                    }
                    if (chatmsg.getGroupMask() && !TextUtils.equals("system-0", chatmsg.getChatId()) && !TextUtils.equals("system-1", chatmsg.getChatId()) && !TextUtils.equals("system-3", chatmsg.getChatId()) && !TextUtils.equals("system-4", chatmsg.getChatId())) {
                    // 屏蔽的信息不与管理
                    } else if ("system-2".equals(chatmsg.getChatId())) {
                    } else {
                        totalCount++;
                    }
                    if (// Collection of traverse after send to unity
                    index == offlinemsgList.length() - 1) {
                        Intent intent = new Intent(XmppAction.ACTION_OFFLINE_MESSAGE_LIST_EVENT_LISTENER);
                        intent.putExtra("chat", chatmsg);
                        intent.putExtra("totalCount", totalCount);
                        Utils.intentAction(getApplicationContext(), intent);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        // Processing is complete
        FinalUserDataBase.getInstance().endTransactionSuccessful();
    }
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint) ChatMsg(com.lingtuan.firefly.vo.ChatMsg) JSONObject(org.json.JSONObject) GroupMemberAvatarVo(com.lingtuan.firefly.contact.vo.GroupMemberAvatarVo)

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