use of com.lingtuan.firefly.contact.vo.GroupMemberAvatarVo in project SmartMesh_Android by SmartMeshFoundation.
the class FinalUserDataBase method getChatMsgEventListChat.
/**
* Get my message history chat records only chat records (forward) used in the
*/
public List<ChatMsg> getChatMsgEventListChat() {
String sql = "select * from " + TableField.TABLE_CHAT_EVENT + " where " + /*+ TableField.FIELD_CHAT_HIDDEN + "=0 and "*/
TableField.FIELD_CHAT_SYSTEM + "=0 " + /*and "
+ TableField.FIELD_RESERVED_DATA7 + "!=1*/
" order by " + TableField.FIELD_CHAT_MSGTIME + " desc ";
Cursor cursor = db.rawQuery(sql, null);
List<ChatMsg> list = new ArrayList<ChatMsg>();
ChatMsg msg;
int unFriendTotle = 0;
while (cursor.moveToNext()) {
msg = new ChatMsg();
msg.setId(cursor.getInt(cursor.getColumnIndex(TableField._ID)));
msg.setContent(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_BODY)));
msg.setGender(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_GENDER)));
msg.setMsgTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_CHAT_MSGTIME)));
msg.setType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_TYPE)));
msg.setUserId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
msg.setUserImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_PIC)));
msg.setUsername(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
msg.setChatId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_ID)));
msg.setUnread(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_UNREAD)));
msg.setSystem(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_SYSTEM)) == 1);
msg.setDismissGroup(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_DISMISSGROUP)) == 1);
msg.setKickGroup(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_KICKGROUP)) == 1);
msg.setMessageId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA1)));
msg.setFriendLog(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA5)));
msg.setGroupMask(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA6)) == 1);
msg.setAtGroupMe(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA8)));
msg.setGroupImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_GROUP_IMAGE)));
msg.setMsgTypeInt(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_OBJECT)));
msg.setTop(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA15)) == 1);
msg.setRemoteSource(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA18)));
msg.setInviteType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA19)));
msg.setInviteSource(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA20)));
msg.setMoney(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA9)));
msg.setMode(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA11)));
msg.setNoticeType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA26)));
if (msg.isTop()) {
msg.setTopTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA16)));
}
if (msg.getChatId().startsWith("group")) {
msg.setGroup(true);
try {
List<GroupMemberAvatarVo> lists = new ArrayList<>();
GroupMemberAvatarVo vo;
String[] split = msg.getUserImage().split("#");
for (int i = 0; i < split.length; i++) {
vo = new GroupMemberAvatarVo();
String[] splitVo = split[i].split("___");
int gender = 2;
try {
gender = Integer.parseInt(splitVo[1]);
} catch (Exception e) {
e.printStackTrace();
}
String image = "";
try {
image = splitVo[0];
} catch (Exception e) {
e.printStackTrace();
}
vo.setGender(gender);
vo.setImage(image);
lists.add(vo);
}
msg.setMemberAvatarList(lists);
} catch (Exception e) {
e.printStackTrace();
}
}
if (!msg.isHidden()) {
list.add(msg);
} else {
if (!msg.getGroupMask()) {
unFriendTotle++;
}
}
}
try {
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getChatId().equals("system-2")) {
list.get(i).setUnread(unFriendTotle);
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
cursor.close();
return list;
}
use of com.lingtuan.firefly.contact.vo.GroupMemberAvatarVo in project SmartMesh_Android by SmartMeshFoundation.
the class XmppService method parseGroupChat.
/**
* Group chat with
*/
private ChatMsg parseGroupChat(Message msg, boolean isGroupSystem) {
if (!TextUtils.isEmpty(msg.getBody())) {
try {
String content = null;
ChatMsg chatmsg = parseBody(msg);
chatmsg.setMsgType(msg.getMsgtype());
String[] uids = chatmsg.getChatId().split("@");
chatmsg.setChatId("group-" + chatmsg.getGroupId());
if (uids.length > 1) {
chatmsg.setChatId(chatmsg.getChatId() + "@" + uids[1]);
}
chatmsg.setGroup(true);
if (chatmsg.getType() == 10000) {
// Offline message
new Thread(new HandleOfflineMsgList(chatmsg, MsgType.groupchat)).start();
return chatmsg;
} else if (!isGroupSystem) {
// Is not a group of notice
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;
}
} else {
// Is a group of notification
if (chatmsg.getType() == 12 || chatmsg.getType() == 13) {
// Invited to join the group chat message by default
if (!TextUtils.isEmpty(chatmsg.getInviteName())) {
chatmsg.setContent(getString(R.string.discuss_group_invite, chatmsg.getInviteName()));
} else {
chatmsg.setContent(getString(R.string.discuss_group_invite_default));
}
} else if (chatmsg.getType() == 14) {
chatmsg.setContent(getString(R.string.discuss_group_kick));
} else if (chatmsg.getType() == 15) {
chatmsg.setContent(getString(R.string.discuss_group_dismiss));
} else if (chatmsg.getType() == 17) {
// Modify the multiplayer session name
chatmsg.setContent(getString(R.string.discuss_group_rename, chatmsg.getGroupName()));
} else if (chatmsg.getType() == 18) {
// Someone quit the multiplayer session
chatmsg.setContent(getString(R.string.discuss_group_outside, chatmsg.getUsername()));
}
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.setDismissGroup(chatmsg.getType() == 15);
chatmsg.setKickGroup(chatmsg.getType() == 14);
Bundle bundle = new Bundle();
bundle.putString("uid", chatmsg.getChatId());
bundle.putBoolean("dismissgroup", chatmsg.isDismissGroup());
bundle.putBoolean("kickgroup", chatmsg.isKickGroup());
Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MESSAGE_GROUP_KICK_LISTENER, bundle);
}
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();
if (isGroupSystem) {
// Is the information system is not to judge whether time display
FinalUserDataBase.getInstance().saveChatMsg(chatmsg, chatmsg.getChatId(), chatmsg.getGroupName(), url.toString(), false);
} else {
// Is not the system information is normal
FinalUserDataBase.getInstance().saveChatMsg(chatmsg, chatmsg.getChatId(), chatmsg.getGroupName(), url.toString());
}
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);
}
chatmsg.setUserImage(url.toString());
if (chatmsg.getType() == 103 && !TextUtils.isEmpty(content)) {
chatmsg.setContent(chatmsg.getShareTitle());
}
return chatmsg;
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
use of com.lingtuan.firefly.contact.vo.GroupMemberAvatarVo in project SmartMesh_Android by SmartMeshFoundation.
the class ChatMsg method parse.
public ChatMsg parse(JSONObject obj) {
if (obj == null) {
return null;
}
setUserId(obj.optString("userid"));
setUsername(obj.optString("username"));
setUserImage(obj.optString("userimage"));
setGender(obj.optInt("usergender"));
setUsersource(obj.optString("usersource"));
setUserfrom(obj.optString("userfrom"));
setType(obj.optInt("type"));
setGroupMask(obj.optInt("mask") == 1 ? true : false);
setFriendLog(obj.optInt("friend_log"));
setGroupName(obj.optString("groupname"));
setGroupImage(obj.optString("groupimage"));
setGroupId(obj.optString("groupid"));
JSONArray array = obj.optJSONArray("groupmember");
if (array != null && array.length() > 0) {
// Group chat image resolution
memberAvatarList = new ArrayList<>();
GroupMemberAvatarVo vo;
for (int i = 0; i < array.length(); i++) {
vo = new GroupMemberAvatarVo().parse(array.optJSONObject(i));
memberAvatarList.add(vo);
}
}
JSONArray arrayAt = obj.optJSONArray("at");
JSONArray arrayAtSource = obj.optJSONArray("atsource");
if (arrayAt != null && arrayAt.length() > 0) {
// Group chat if @ I parse
for (int i = 0; i < arrayAt.length(); i++) {
try {
String uid = arrayAt.optString(i);
String meuid = NextApplication.myInfo.getLocalId();
if (arrayAtSource != null && arrayAtSource.length() == arrayAt.length()) {
uid = uid + "@" + arrayAtSource.optString(i);
meuid = meuid + "@" + XmppUtils.SERVER_NAME;
}
if (meuid.equals(uid)) {
if (obj.optInt("atall", 0) == 1) {
setAtGroupMe(2);
} else {
setAtGroupMe(1);
}
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
setAtGroupMe(0);
}
if (// Offline message set
getType() == 10000 && obj.has("offlinelist")) {
setOfflinmsgList(obj.optJSONArray("offlinelist"));
return this;
}
setContent(obj.optString("content"));
setCover(obj.optString("cover"));
setSecond(obj.optString("second"));
setLon(obj.optString("lon"));
setLat(obj.optString("lat"));
setThirdName(obj.optString("name"));
setShopAddress(obj.optString("address"));
setThirdImage(obj.optString("image"));
setThirdId(obj.optString("id"));
setThirdGender(obj.optString("gender"));
setCardSign(obj.optString("sign"));
setCreateAge(obj.optInt("createrid"));
setCreateGender(obj.optInt("creatergender"));
setCreategSign(obj.optString("creatersightml"));
setCreateId(obj.optInt("createrid"));
setCreateImage(obj.optString("createrimage"));
setCreateName(obj.optString("creatername"));
setSort(obj.optInt("sort"));
setGuest(obj.optInt("guest"));
setInviteMsg(obj.optString("message"));
setCreateTime(obj.optLong("time"));
setInviteId(obj.optInt("id"));
if (obj.has("inviteid")) {
setInviteId(obj.optInt("inviteid"));
}
if (obj.has("invitesource")) {
setInviteSource(obj.optString("invitesource"));
}
setInviteImage(obj.optString("inviteimage"));
setDatingSOSId(obj.optInt("invite_id"));
setShareFriendName(obj.optString("friendname"));
setModifyType(obj.optInt("modifytype"));
setSceneType(obj.optInt("scenetype"));
setInviteType(obj.optInt("msgtype"));
// Share share news
setShareUrl(obj.optString("url"));
setShareTitle(obj.optString("title"));
setShareThumb(obj.optString("thumb"));
// The url of the live
setVideotype(obj.optInt("videotype"));
setLivingUrl(obj.optString("livingUrl"));
// Group name of the inviter
setInviteName(obj.optString("invitename"));
// Group by the name of the inviter
setBeinviteName(obj.optString("beinvitename"));
// Whether the administrator
setIs_manager(obj.optInt("is_manager"));
// The total number can be modified
setLefttimes(obj.optInt("lefttimes", 0));
setMoney(obj.optString("money"));
setNumber(obj.optString("number"));
setMode(obj.optString("mode"));
setRedpacketId(obj.optString("rid"));
setVip_level(obj.optString("vip_level"));
setVip_type(obj.optString("vip_type"));
setIs_vip(obj.optBoolean("is_vip", false));
setMsgName(obj.optString("msgname"));
setExtra(obj.optString("extra"));
setLive_level(obj.optInt("live_level"));
setSource(obj.optString("msgsource"));
setRemoteSource(obj.optString("msgsource"));
setSendName(obj.optString("sendname"));
setPropName(obj.optString("propname"));
setPropNum(obj.optInt("propnum"));
setPropId(obj.optString("propid"));
setNum(obj.optInt("num"));
setText(obj.optString("text"));
setLink(obj.optString("link"));
setFee(obj.optString("fee"));
setFromAddress(obj.optString("fromaddress"));
setToAddress(obj.optString("toaddress"));
setTxBlockNumber(obj.optString("txblocknumber"));
setNoticeType(obj.optInt("noticetype"));
return this;
}
use of com.lingtuan.firefly.contact.vo.GroupMemberAvatarVo 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();
}
}
use of com.lingtuan.firefly.contact.vo.GroupMemberAvatarVo in project SmartMesh_Android by SmartMeshFoundation.
the class FinalUserDataBase method getChatMsgEventList.
/**
*My chat history record contains information system information
*
* @return
*/
public List<ChatMsg> getChatMsgEventList() {
List<ChatMsg> list = new ArrayList<ChatMsg>();
if (db != null) {
String sql = "select * from " + TableField.TABLE_CHAT_EVENT + /*" where " +TableField.FIELD_RESERVED_DATA7 + " is not 1*/
" order by " + TableField.FIELD_CHAT_MSGTIME + " desc ";
Cursor cursor = db.rawQuery(sql, null);
ChatMsg msg;
int total = 0;
int unFriendTotle = 0;
while (cursor.moveToNext()) {
msg = new ChatMsg();
msg.setId(cursor.getInt(cursor.getColumnIndex(TableField._ID)));
msg.setContent(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_BODY)));
msg.setGender(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_GENDER)));
msg.setMsgTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_CHAT_MSGTIME)));
msg.setType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_TYPE)));
msg.setUserId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
msg.setUserImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_PIC)));
msg.setUsername(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
msg.setChatId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_ID)));
msg.setHidden(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_HIDDEN)) == 1 ? true : false);
msg.setUnread(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_UNREAD)));
msg.setSystem(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_SYSTEM)) == 1 ? true : false);
msg.setDismissGroup(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_DISMISSGROUP)) == 1 ? true : false);
msg.setKickGroup(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_KICKGROUP)) == 1 ? true : false);
msg.setMessageId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA1)));
msg.setShareFriendName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA2)));
msg.setModifyType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA3)));
msg.setFriendLog(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA5)));
msg.setGroupMask(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA6)) == 1 ? true : false);
msg.setAtGroupMe(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA8)));
msg.setGroupImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_GROUP_IMAGE)));
msg.setMsgTypeInt(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_OBJECT)));
msg.setCreateName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_CREATENAME)));
msg.setVip_type(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA12)));
msg.setVip_level(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA13)));
msg.setIs_vip(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA14)) == 1);
msg.setTop(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA15)) == 1);
msg.setRemoteSource(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA18)));
msg.setInviteType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA19)));
msg.setInviteSource(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA20)));
msg.setMoney(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA9)));
msg.setMode(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA11)));
msg.setNoticeType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA26)));
if (msg.isTop()) {
msg.setTopTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA16)));
}
if (msg.getChatId().startsWith("group")) {
msg.setGroup(true);
try {
List<GroupMemberAvatarVo> lists = new ArrayList<>();
GroupMemberAvatarVo vo;
String[] split = msg.getUserImage().split("#");
for (int i = 0; i < split.length; i++) {
vo = new GroupMemberAvatarVo();
String[] splitVo = split[i].split("___");
int gender = 2;
try {
gender = Integer.parseInt(splitVo[1]);
} catch (Exception e) {
e.printStackTrace();
}
String image = "";
try {
image = splitVo[0];
} catch (Exception e) {
e.printStackTrace();
}
vo.setGender(gender);
vo.setImage(image);
lists.add(vo);
}
msg.setMemberAvatarList(lists);
} catch (Exception e) {
e.printStackTrace();
}
}
if (!msg.isHidden()) {
list.add(msg);
if (msg.getChatId().equals("system-0") || msg.getChatId().equals("system-1") || msg.getChatId().equals("system-3") || msg.getChatId().equals("system-4") || msg.getChatId().equals("system-5")) {
total += msg.getUnread();
} else if (!msg.getGroupMask()) {
total += msg.getUnread();
}
} else {
if (!msg.isSystem() && !msg.getGroupMask()) {
unFriendTotle += msg.getUnread();
}
}
if (!msg.isGroup() && msg.getMsgTypeInt() != 3 && !TextUtils.isEmpty(msg.getChatId()) && !TextUtils.equals("everyone", msg.getChatId()) && !msg.getChatId().startsWith("system")) {
UserBaseVo baseVo = FinalUserDataBase.getInstance().getUserBaseVoByUid(msg.getChatId());
if (baseVo != null && !TextUtils.isEmpty(baseVo.getShowName())) {
msg.setUsername(baseVo.getShowName());
}
}
}
try {
map.put("totalunread", total);
} catch (Exception e) {
e.printStackTrace();
}
cursor.close();
}
return list;
}
Aggregations