use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ContactSelectedUI method forwardImgMethod.
/**
* Sending pictures method
* @param picturePath Image path
*/
private void forwardImgMethod(String uid, String picturePath, String userName, String avatarUrl, boolean isGroup, boolean isSend) {
float density = getResources().getDisplayMetrics().density;
// mContext.getResources().getDisplayMetrics().widthPixels;
int screenWidth = Constants.MAX_IMAGE_WIDTH;
// mContext.getResources().getDisplayMetrics().heightPixels;
int screenHeight = Constants.MAX_IMAGE_HEIGHT;
int width = (int) (120 * density);
Bitmap bmp = BitmapUtils.getimage(picturePath, width, width, 10);
Bitmap bmpUpload = BitmapUtils.getimage(picturePath, screenWidth, screenHeight, Constants.MAX_KB);
BitmapUtils.saveBitmap2SD(bmp, 10, false);
String uploadPath = BitmapUtils.saveBitmap2SD(bmpUpload, screenWidth, true).getPath();
String url = uploadPath;
boolean successed = true;
if (uid.equals("everyone")) {
XmppMessageUtil.getInstance().sendEnterLeaveEveryOne(0, false);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
ChatMsg msg = createImageChatMsg(uid, url, userName, avatarUrl, BitmapUtils.BitmapToBase64String(bmp), isGroup, isSend);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
XmppMessageUtil.getInstance().sendEnterLeaveEveryOne(0, true);
if (appNetService != null) {
successed = appNetService.handleSendPicutre(url, true, uid, msg.getMessageId());
}
if (msg.getSend() == 0 && !successed) {
msg.setSend(0);
}
} else if (isGroup) {
createImageChatMsg(uid, url, userName, avatarUrl, BitmapUtils.BitmapToBase64String(bmp), isGroup, isSend);
} 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.setType(1);
msg.setContent(url);
msg.setLocalUrl(url);
msg.setCover(BitmapUtils.BitmapToBase64String(bmp));
msg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
msg.setChatId(uid);
msg.setOffLineMsg(true);
msg.setSend(1);
msg.setMessageId(UUID.randomUUID().toString());
msg.setMsgTime(System.currentTimeMillis() / 1000);
msg.setShowTime(FinalUserDataBase.getInstance().isOffLineShowTime(uid, msg.getMsgTime()));
successed = appNetService.handleSendPicutre(url, false, uid, msg.getMessageId());
if (!successed) {
msg.setSend(0);
}
FinalUserDataBase.getInstance().saveChatMsg(msg, uid, userName, avatarUrl);
} else {
createImageChatMsg(uid, url, userName, avatarUrl, BitmapUtils.BitmapToBase64String(bmp), isGroup, isSend);
}
}
if (bmp != null && !bmp.isRecycled()) {
bmp.recycle();
}
if (bmpUpload != null && !bmpUpload.isRecycled()) {
bmpUpload.recycle();
}
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ContactSelectedUI method initData.
@Override
protected void initData() {
setTitle(getString(R.string.chatting_selected_title));
// -1 default 0 close 1 open
int openSmartMesh = MySharedPrefs.readInt1(NextApplication.mContext, MySharedPrefs.FILE_USER, MySharedPrefs.KEY_NO_NETWORK_COMMUNICATION + NextApplication.myInfo.getLocalId());
if (openSmartMesh == -1) {
bindService(new Intent(this, AppNetService.class), serviceConn, Activity.BIND_AUTO_CREATE);
}
if (getIntent() != null) {
msgList = (ArrayList<ChatMsg>) getIntent().getSerializableExtra("msglist");
if (msgList != null && msgList.size() >= 0) {
if (!TextUtils.isEmpty(msgList.get(0).getForwardLeaveMsg())) {
linkTitle = msgList.get(0).getForwardLeaveMsg();
}
}
}
mListView.addHeaderView(headerView);
mAdapter = new MessageEventAdapter(null, this);
mListView.setAdapter(mAdapter);
new Thread(new UpdateMessage()).start();
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class DiscussGroupMemberListUI 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(name);
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(), name, url, false);
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class DiscussGroupSettingUI method inviteOthersChatMsg.
/**
* Forge a invite others to join group chat message
*/
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(nameEdit.getText().toString());
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(), nameEdit.getText().toString(), url, false);
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class DiscussGroupSettingUI method reNameChatMsg.
/**
* Forge a system modification group chat information
*/
private void reNameChatMsg(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(17);
chatmsg.setSend(1);
chatmsg.setContent(getString(R.string.discuss_group_rename, chatmsg.getGroupName()));
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);
}
Aggregations