use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ChattingUI method sentTextMethod.
/**
* Send text
*/
private void sentTextMethod() {
final String content = mInputContent.getText().toString().trim();
String atIds = chattingManager.getSbAtGroupSelectIds();
Editable mEditable = mInputContent.getText();
boolean isAtAll = chattingManager.isAtAll(mEditable.toString());
boolean successed = true;
if (uid.equals(Constants.APP_EVERYONE)) {
ChatMsg msg = XmppMessageUtil.getInstance().sendText(uid, content, isAtAll, atIds, userName, avatarUrl, isGroup, !(isDismissGroup || isKickGroup));
if (appNetService != null) {
successed = appNetService.handleSendString(content, true, "", msg.getMessageId());
}
if (msg.getSend() == 0 && !successed) {
msg.setSend(0);
}
mAdapter.addChatMsg(msg, true);
} else if (uid.equals(Constants.APP_MESH)) {
// send mesh text
ChatMsg msg = XmppMessageUtil.getInstance().sendText(uid, content, isAtAll, atIds, userName, avatarUrl, isGroup, !(isDismissGroup || isKickGroup));
mAdapter.addChatMsg(msg, true);
} else if (isGroup) {
ChatMsg msg = XmppMessageUtil.getInstance().sendText(uid, content, isAtAll, atIds, userName, avatarUrl, isGroup, !(isDismissGroup || isKickGroup));
mAdapter.addChatMsg(msg, true);
} else {
boolean foundPeople = false;
if (appNetService != null && appNetService.getwifiPeopleList() != null) {
for (// All users need to traverse, find out the corresponding touid users
WifiPeopleVO vo : // All users need to traverse, find out the corresponding touid users
appNetService.getwifiPeopleList()) {
if (uid.equals(vo.getLocalId())) {
foundPeople = true;
break;
}
}
}
if (// With no net with no net send messages
foundPeople) {
ChatMsg msg = new ChatMsg();
msg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
msg.setChatId(uid);
msg.setType(0);
msg.setSend(1);
msg.setMsgTime(System.currentTimeMillis() / 1000);
msg.setShowTime(FinalUserDataBase.getInstance().isOffLineShowTime(uid, msg.getMsgTime()));
msg.setContent(content);
msg.setOffLineMsg(true);
msg.setMessageId(UUID.randomUUID().toString());
if (appNetService != null) {
successed = appNetService.handleSendString(content, false, uid, msg.getMessageId());
}
if (!successed) {
msg.setSend(0);
}
mAdapter.addChatMsg(msg, true);
File recvFile = new File(SDCardCtrl.getOfflinePath() + File.separator + uid + ".jpg");
String imageAvatar = "file://" + recvFile.getAbsolutePath();
FinalUserDataBase.getInstance().saveChatMsg(msg, uid, isGroup ? "offline" : userName, imageAvatar);
} else {
ChatMsg msg = XmppMessageUtil.getInstance().sendText(uid, content, isAtAll, atIds, userName, avatarUrl, isGroup, !(isDismissGroup || isKickGroup));
mAdapter.addChatMsg(msg, true);
}
}
mInputContent.setText("");
listView.setSelection(mAdapter.getCount() - 1);
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ChatAdapter method updateAgree.
public void updateAgree(boolean agree, String messageId) {
if (TextUtils.isEmpty(messageId)) {
return;
}
int count = mList.size();
for (int i = 0; i < count; i++) {
ChatMsg msg = mList.get(i);
if (TextUtils.equals(msg.getMessageId(), messageId)) {
msg.setCover(agree ? "1" : "2");
notifyDataSetChanged();
break;
}
}
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ChatAdapter method removeSelectList.
/**
* Delete the selected item
*/
public synchronized void removeSelectList() {
if (!selectedList.isEmpty()) {
for (Entry<String, ChatMsg> s : selectedList.entrySet()) {
if (// 图片
s.getValue().getType() == 1) {
String url = s.getValue().getLocalUrl();
if (TextUtils.isEmpty(url)) {
url = s.getValue().getContent();
} else {
File file = new File(url);
if (file.exists()) {
url = "file://" + s.getValue().getLocalUrl();
} else {
url = s.getValue().getContent();
}
}
for (int i = 0; i < imagePathList.size(); i++) {
if (imagePathList.get(i).equals(url)) {
imagePathList.remove(i);
break;
}
}
}
mList.remove(s.getValue());
}
}
rollbackSelected();
notifyDataSetChanged();
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ChatAdapter method updateSendStatus.
/*A web chat to update the delivery status*/
public ChatMsg updateSendStatus(int send, int state, String msgId, String localUrl, int collectState) {
if (mList == null) {
return null;
}
ChatMsg chatMsg = null;
int count = mList.size();
for (int i = count - 1; i > -1; i--) {
if (mList.get(i).getMessageId() != null && mList.get(i).getMessageId().equals(msgId)) {
chatMsg = mList.get(i);
if (send != -1) {
chatMsg.setSend(send);
}
if (!TextUtils.isEmpty(localUrl)) {
chatMsg.setLocalUrl(localUrl);
}
if (collectState != -1) {
chatMsg.setDatingSOSId(collectState);
}
if (state != -2) {
// To get their state not only to update the state was 2
chatMsg.setInviteType(state);
}
notifyDataSetChanged();
break;
}
}
return chatMsg;
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class MessageEventAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder h;
ChatMsg msg = mList.get(position);
if (convertView == null) {
h = new Holder();
convertView = View.inflate(mContext, R.layout.item_msg_evnet, null);
h.bg = (LinearLayout) convertView.findViewById(R.id.item_bg);
h.avatarShape = (CharAvatarView) convertView.findViewById(R.id.item_avatar);
h.listenerIcon = (ImageView) convertView.findViewById(R.id.item_msg_event_listener);
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.unread = (TextView) convertView.findViewById(R.id.item_unread);
h.atGroupMe = (TextView) convertView.findViewById(R.id.item_at);
h.unReadIcon = (ImageView) convertView.findViewById(R.id.item_unread_icon);
h.groupImageView = (DiscussGroupImageView) convertView.findViewById(R.id.group_avatar);
h.y_m_d = (ImageView) convertView.findViewById(R.id.y_m_d);
h.vipLevel = (ImageView) convertView.findViewById(R.id.vipLevel);
convertView.setTag(h);
} else {
h = (Holder) convertView.getTag();
}
if (msg.isTop()) {
h.bg.setBackgroundResource(R.drawable.scrollview_top_item_bg);
} else {
h.bg.setBackgroundResource(R.drawable.scrollview_item_bg);
}
String nickname = msg.getUsername();
String content = msg.getContent();
String url = msg.getUserImage();
int resId = 0;
h.groupImageView.setVisibility(View.GONE);
h.avatarShape.setVisibility(View.VISIBLE);
if (msg.isAtGroupMe() == 1) {
// I was @
h.atGroupMe.setVisibility(View.VISIBLE);
h.atGroupMe.setText(mContext.getString(R.string.chat_at_me));
} else if (msg.isAtGroupMe() == 2) {
// Someone @ all members
h.atGroupMe.setVisibility(View.VISIBLE);
h.atGroupMe.setText(mContext.getString(R.string.chat_at_all));
} else {
// No one @ I
h.atGroupMe.setVisibility(View.GONE);
}
if (msg.isSystem()) {
int type = msg.getType();
if (type == 0) {
// A friend request
url = "drawable://" + R.drawable.icon_msg_contact_add;
resId = R.drawable.icon_msg_contact_add;
nickname = mContext.getString(R.string.chat_friend_notify);
content = mContext.getResources().getString(R.string.contact_add_content, msg.getUsername());
} else if (type == 300) {
// A traqns
url = "drawable://" + R.drawable.icon_msg_trans;
resId = R.drawable.icon_msg_trans;
nickname = mContext.getString(R.string.chat_token_notify);
if (msg.getNoticeType() == 0) {
if (TextUtils.equals("0", msg.getMode())) {
// eth
if (msg.getInviteType() == 0) {
content = mContext.getString(R.string.wallet_trans_msg_eth, msg.getMoney());
} else {
content = mContext.getString(R.string.wallet_trans_msg_eth_failed, msg.getMoney());
}
} else if (TextUtils.equals("1", msg.getMode())) {
if (msg.getInviteType() == 0) {
content = mContext.getString(R.string.wallet_trans_msg_smt, msg.getMoney());
} else {
content = mContext.getString(R.string.wallet_trans_msg_smt_failed, msg.getMoney());
}
} else if (TextUtils.equals("2", msg.getMode())) {
if (msg.getInviteType() == 0) {
content = mContext.getString(R.string.wallet_trans_msg_mesh, msg.getMoney());
} else {
content = mContext.getString(R.string.wallet_trans_msg_mesh_failed, msg.getMoney());
}
}
} else {
if (TextUtils.equals("0", msg.getMode())) {
// eth
if (msg.getInviteType() == 0) {
content = mContext.getString(R.string.wallet_trans_collect_eth, msg.getMoney());
} else {
content = mContext.getString(R.string.wallet_trans_collect_eth_failed, msg.getMoney());
}
} else if (TextUtils.equals("1", msg.getMode())) {
if (msg.getInviteType() == 0) {
content = mContext.getString(R.string.wallet_trans_collect_smt, msg.getMoney());
} else {
content = mContext.getString(R.string.wallet_trans_collect_smt_failed, msg.getMoney());
}
} else if (TextUtils.equals("2", msg.getMode())) {
if (msg.getInviteType() == 0) {
content = mContext.getString(R.string.wallet_trans_collect_mesh, msg.getMoney());
} else {
content = mContext.getString(R.string.wallet_trans_collect_mesh_failed, msg.getMoney());
}
}
}
}
} else {
if (Constants.APP_EVERYONE.equals(msg.getChatId())) {
url = "drawable://" + R.drawable.icon_everyone;
nickname = mContext.getResources().getString(R.string.everyone);
resId = R.drawable.icon_everyone;
} else if (Constants.APP_MESH.equals(msg.getChatId())) {
url = "drawable://" + R.drawable.icon_wifimesh;
nickname = mContext.getResources().getString(R.string.wifimesh);
resId = R.drawable.icon_wifimesh;
}
content = getContent(msg, content);
}
Utils.formatUnreadCount(h.unread, msg.getUnread());
h.unReadIcon.setVisibility(View.GONE);
h.listenerIcon.setVisibility(View.GONE);
h.unread.setVisibility(msg.getUnread() > 0 ? View.VISIBLE : View.GONE);
if (msg.getGroupMask()) {
if (Constants.APP_EVERYONE.equals(msg.getChatId()) || "system-0".equals(msg.getChatId()) || "system-1".equals(msg.getChatId()) || "system-3".equals(msg.getChatId()) || "system-4".equals(msg.getChatId()) || "system-5".equals(msg.getChatId())) {
// If is the invitation message or group system, there is no shielding function
} else {
h.listenerIcon.setVisibility(View.VISIBLE);
h.unread.setVisibility(View.GONE);
if (msg.getUnread() > 0) {
h.unReadIcon.setVisibility(View.VISIBLE);
}
}
}
if (msg.isGroup() || msg.getMsgTypeInt() == 3) {
h.avatarShape.setVisibility(View.GONE);
h.groupImageView.setVisibility(View.VISIBLE);
if (msg.getMemberAvatarUserBaseList() != null) {
h.groupImageView.setMember(msg.getMemberAvatarUserBaseList());
}
} else {
if (!TextUtils.isEmpty(url)) {
if (url.startsWith("drawable://")) {
NextApplication.displayCircleImage(h.avatarShape, null);
h.avatarShape.setImageResource(resId);
} else {
h.avatarShape.setText(msg.getUsername(), h.avatarShape, url);
}
} else {
h.avatarShape.setText(msg.getUsername(), h.avatarShape, url);
}
}
h.nickname.setText(nickname);
final CharSequence charSequence = NextApplication.mSmileyParser.addSmileySpans1(content);
h.content.setText(charSequence);
Utils.setLoginTime(mContext, h.time, msg.getMsgTime());
return convertView;
}
Aggregations