use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ChatHistoryUI method onClick.
@Override
public void onClick(View v) {
super.onClick(v);
switch(v.getId()) {
case R.id.app_btn_right:
if (mAdapter.getSelectedList() == null || mAdapter.getSelectedList().size() == 0) {
MyToast.showToast(this, getString(R.string.chat_file_empty));
return;
}
ArrayList<ChatMsg> list = new ArrayList<>();
for (Map.Entry<String, ChatMsg> s : mAdapter.getSelectedList().entrySet()) {
list.add(s.getValue());
}
Intent data = new Intent();
data.putExtra("msglist", list);
setResult(RESULT_OK, data);
finish();
break;
default:
break;
}
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ChattingManager method createAudioChatMsg.
/**
* Create a voice chat entity class
*/
private ChatMsg createAudioChatMsg(String uid, String content, String uName, String avatarUrl, String second, boolean isSend) {
ChatMsg chatMsg = new ChatMsg();
chatMsg.setType(2);
chatMsg.setContent(content);
chatMsg.setLocalUrl(content);
chatMsg.setSecond(second);
chatMsg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
String jid = uid + "@" + XmppUtils.SERVER_NAME;
if (isGroup) {
jid = uid.replace("group-", "") + "@group." + XmppUtils.SERVER_NAME;
}
Message msg = new Message(jid, Type.chat);
chatMsg.setMessageId(msg.getPacketID());
if (isGroup) {
//
msg.setMsgtype(MsgType.groupchat);
chatMsg.setGroup(isGroup);
chatMsg.setChatId(uid);
chatMsg.setSource(NextApplication.mContext.getString(R.string.app_name));
chatMsg.setUserfrom(mContext.getString(R.string.app_name));
chatMsg.setUsersource(XmppUtils.SERVER_NAME);
msg.setBody(chatMsg.toGroupChatJsonObject());
} else {
chatMsg.setSource(mContext.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", 1);
bundle.putString("uid", uid);
bundle.putString("username", uName);
bundle.putString("avatarurl", avatarUrl);
bundle.putSerializable("chatmsg", chatMsg);
Utils.intentService(mContext, LoadDataService.class, LoadDataService.ACTION_FILE_UPLOAD_CHAT, LoadDataService.ACTION_FILE_UPLOAD_CHAT, bundle);
}
return chatMsg;
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ChattingManager method setVoiceInfo.
public void setVoiceInfo(int second) {
boolean successed = true;
if (uid.equals(Constants.APP_EVERYONE)) {
ChatMsg msg = createAudioChatMsg(uid, SDCardCtrl.getAudioPath() + File.separator + audioName, userName, avatarUrl, second + "", isSend);
if (appNetService != null) {
successed = appNetService.handleSendVoice(second, SDCardCtrl.getAudioPath() + File.separator + audioName, true, uid, msg.getMessageId());
}
if (msg.getSend() == 0 && !successed) {
msg.setSend(0);
}
mAdapter.addChatMsg(msg, true);
} else if (isGroup) {
ChatMsg msg = createAudioChatMsg(uid, SDCardCtrl.getAudioPath() + File.separator + audioName, userName, avatarUrl, second + "", isSend);
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.setType(2);
msg.setContent(SDCardCtrl.getAudioPath() + File.separator + audioName);
msg.setLocalUrl(SDCardCtrl.getAudioPath() + File.separator + audioName);
msg.setSecond(second + "");
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()));
if (appNetService != null) {
successed = appNetService.handleSendVoice(second, SDCardCtrl.getAudioPath() + File.separator + audioName, false, uid, msg.getMessageId());
}
if (!successed) {
msg.setSend(0);
}
mAdapter.addChatMsg(msg, true);
FinalUserDataBase.getInstance().saveChatMsg(msg, uid, userName, avatarUrl);
} else {
ChatMsg msg = createAudioChatMsg(uid, SDCardCtrl.getAudioPath() + File.separator + audioName, userName, avatarUrl, second + "", isSend);
mAdapter.addChatMsg(msg, true);
}
}
listView.setSelection(mAdapter.getCount());
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ChattingUI method deleteMethod.
/**
* Forward delete methods
*/
private void deleteMethod() {
if (mAdapter.getSelectedList() == null || mAdapter.getSelectedList().size() == 0) {
showToast(getString(R.string.chat_file_empty));
return;
}
int titleIds = isSceneDelete ? R.string.chatting_selected_delete : R.string.chatting_selected_relay;
if (isSceneDelete) {
// delete
MyViewDialogFragment mdf = new MyViewDialogFragment();
mdf.setTitleAndContentText(getString(titleIds), null);
mdf.setOkCallback(new MyViewDialogFragment.OkCallback() {
@Override
public void okBtn() {
if (isSceneDelete) {
// Delete
Map<String, ChatMsg> selectedList = mAdapter.getSelectedList();
ChatMsg msg = null;
if (!selectedList.isEmpty()) {
for (Map.Entry<String, ChatMsg> s : selectedList.entrySet()) {
FinalUserDataBase.getInstance().deleteChatMsgBymessageId(s.getValue().getMessageId());
if (msg != null && s.getValue().getMsgTime() > msg.getMsgTime()) {
continue;
}
msg = s.getValue();
}
}
mAdapter.removeSelectList();
if (msg == null) {
return;
}
if (msg != null) {
msg.setUsername(userName);
msg.setUserImage(avatarUrl);
}
FinalUserDataBase.getInstance().updateChatEventContent(uid, msg);
MyToast.showToast(ChattingUI.this, getString(R.string.delete_success));
} else {
// Forwarding
}
rollbackScene();
}
});
mdf.show(getSupportFragmentManager(), "mdf");
} else {
// Forwarding
ArrayList<ChatMsg> list = new ArrayList<>();
for (Map.Entry<String, ChatMsg> s : mAdapter.getSelectedList().entrySet()) {
list.add(s.getValue());
}
Intent intent = new Intent(this, ContactSelectedUI.class);
intent.putExtra("msglist", list);
startActivity(intent);
Utils.openNewActivityAnim(this, false);
}
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ChatAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder h;
final ChatMsg msg = mList.get(position);
final int type = getItemViewType(position);
if (convertView == null) {
h = new Holder();
switch(type) {
case // The other side of the text information
LEFT_TEXT:
convertView = View.inflate(mContext, R.layout.item_chatting_left_text, null);
break;
case // The other side of the picture information
LEFT_IMAGE:
convertView = View.inflate(mContext, R.layout.item_chatting_left_image, null);
break;
case // Each other's voice messages
LEFT_AUDIO:
convertView = View.inflate(mContext, R.layout.item_chatting_left_audio, null);
break;
case // The other side of the business card information
LEFT_CARD:
convertView = View.inflate(mContext, R.layout.item_chatting_left_card, null);
break;
case // Share information
LEFT_SHARE:
convertView = View.inflate(mContext, R.layout.item_chatting_left_share, null);
break;
/**
*----------------------------------------------------
*/
case // His text message
RIGHT_TEXT:
convertView = View.inflate(mContext, R.layout.item_chatting_right_text, null);
break;
case // His picture information
RIGHT_IMAGE:
convertView = View.inflate(mContext, R.layout.item_chatting_right_image, null);
break;
case // His voice messages
RIGHT_AUDIO:
convertView = View.inflate(mContext, R.layout.item_chatting_right_audio, null);
break;
case // Your business card information
RIGHT_CARD:
convertView = View.inflate(mContext, R.layout.item_chatting_right_card, null);
break;
case // Share information
RIGHT_SHARE:
convertView = View.inflate(mContext, R.layout.item_chatting_right_share, null);
break;
case // The system informs the information
NOTIF:
convertView = View.inflate(mContext, R.layout.item_chatting_notif, null);
break;
case // Received the documents
LEFT_SEND_FILE:
convertView = View.inflate(mContext, R.layout.item_chatting_left_file, null);
break;
case // From the file
RIGHT_SEND_FILE:
convertView = View.inflate(mContext, R.layout.item_chatting_right_file, null);
break;
}
h.leftLinear = (LinearLayout) convertView.findViewById(R.id.item_chatting_body_linear);
h.imageUploadLinear = (LinearLayout) convertView.findViewById(R.id.item_chatting_image_upload_linear);
h.avatar = (CharAvatarView) convertView.findViewById(R.id.item_chatting_avatar);
h.mNickname = (TextView) convertView.findViewById(R.id.item_chatting_nickname);
h.content = (TextView) convertView.findViewById(R.id.item_chatting_text);
h.time = (TextView) convertView.findViewById(R.id.item_chatting_time);
h.icon = (ImageView) convertView.findViewById(R.id.item_chatting_icon);
h.msgWarnning = (ImageView) convertView.findViewById(R.id.item_chatting_warnning);
h.msgImage = (ImageView) convertView.findViewById(R.id.item_chatting_image);
h.mNotifBar = (ProgressBar) convertView.findViewById(R.id.item_chatting_notif);
h.shopAddress = (TextView) convertView.findViewById(R.id.item_chatting_third_address);
h.shopName = (TextView) convertView.findViewById(R.id.item_chatting_third_name);
h.shopImage = (CharAvatarView) convertView.findViewById(R.id.item_chatting_third_avatar);
h.audioTimes = (TextView) convertView.findViewById(R.id.item_chatting_audio_times);
h.audioIcon = (ImageView) convertView.findViewById(R.id.item_chatting_audio_icon);
h.selectBox = (ImageView) convertView.findViewById(R.id.item_chatting_select_iv);
h.relativeLayout = (RelativeLayout) convertView.findViewById(R.id.relativelayout);
/**
************************Documents related to****************************************
*/
h.imgFileLogo = (ImageView) convertView.findViewById(R.id.img_file_logo);
h.txtFileName = (TextView) convertView.findViewById(R.id.txt_file_name);
h.txtFileSize = (TextView) convertView.findViewById(R.id.txt_file_size);
h.txtFileSendState = (TextView) convertView.findViewById(R.id.txt_file_sent_state);
h.progressbarFile = (ProgressBar) convertView.findViewById(R.id.file_send_progress);
convertView.setTag(h);
} else {
h = (Holder) convertView.getTag();
}
if (h.selectBox != null) {
if (delete || forwarding || isUpload) {
h.selectBox.setVisibility(View.VISIBLE);
int resId = selectedList.get(msg.getMessageId()) == null ? R.drawable.checkbox_unselected : R.drawable.checkbox_selected;
h.selectBox.setImageResource(resId);
if (h.relativeLayout != null) {
h.relativeLayout.setVisibility(View.VISIBLE);
h.relativeLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (forwarding && (type == LEFT_SEND_FILE || type == RIGHT_SEND_FILE)) {
if (msg.getCreateTime() > 0) {
// One to one message file
long time = msg.getCreateTime() + 7 * 24 * 3600 - System.currentTimeMillis() / 1000;
if (time <= 0) {
// Has the failure
return;
}
}
}
// Voice is selected //Except upload chat logs
if (isUpload || !(forwarding && (type == LEFT_AUDIO || type == RIGHT_AUDIO || type == LEFT_DATIONG_SOS))) {
selectedItem(msg);
}
}
});
}
} else {
if (h.relativeLayout != null) {
h.relativeLayout.setVisibility(View.GONE);
}
h.selectBox.setVisibility(View.GONE);
}
}
switch(type) {
// The other side of the text information
case LEFT_TEXT:
case // His text message
RIGHT_TEXT:
showTextMsg(h, msg, type);
break;
// The other side of the picture information
case LEFT_IMAGE:
case // His picture information
RIGHT_IMAGE:
showImgMsg(h, msg);
break;
// Each other's voice messages
case LEFT_AUDIO:
case // His voice messages
RIGHT_AUDIO:
setAudioContent(h, position, type);
break;
// The other side of the business card information
case LEFT_CARD:
case // Your business card information
RIGHT_CARD:
showCardMsg(h, msg);
break;
case // Send the file
RIGHT_SEND_FILE:
showFileInfo(h, msg, true);
break;
case // Received the documents
LEFT_SEND_FILE:
showFileInfo(h, msg, true);
break;
// Share information
case LEFT_SHARE:
case RIGHT_SHARE:
showShareMsg(h, msg);
break;
case // The system informs the information
NOTIF:
showSystemMsg(h, msg);
return convertView;
}
h.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
UserBaseVo vo = new UserBaseVo();
vo.setUsername(msg.getUsername());
vo.setLocalId(msg.getUserId());
vo.setThumb(msg.getUserImage());
vo.setFriendLog(msg.getFriendLog());
intentPeopleDetailUI(vo);
}
});
h.avatar.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if ((isGroup || TextUtils.equals(Constants.APP_EVERYONE, msg.getChatId()) || TextUtils.equals(Constants.APP_MESH, msg.getChatId())) && !msg.isMe() && mInputContent != null && mChattingManager != null) {
// Long press head @ function
int selectIndex = mInputContent.getSelectionStart();
Editable mEditable = mInputContent.getEditableText();
mEditable.insert(selectIndex, "@" + msg.getRealname() + " ");
mChattingManager.sbAtGroupSelectIds.add(msg.getUserId());
Utils.showKeyBoard(mInputContent);
if (AtGroupParser.getInstance() == null) {
AtGroupParser.init(new String[] { msg.getRealname() + " " }, new String[] { msg.getUserId() });
} else {
AtGroupParser.getInstance().addParse(msg.getRealname() + " ", msg.getUserId());
}
}
return true;
}
});
if (h.leftLinear != null) {
h.leftLinear.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// Long chat content according to the event
return onLongClickLogic(msg);
}
});
}
String url = "";
if (msg.isMe()) {
url = NextApplication.myInfo.getThumb();
} else {
url = msg.getUserImage();
if (!TextUtils.isEmpty(tempAvatar.get(msg.getUserId()))) {
url = tempAvatar.get(msg.getUserId());
}
}
h.avatar.setText(msg.getUsername(), h.avatar, url);
h.time.setVisibility(msg.isShowTime() ? View.VISIBLE : View.GONE);
Utils.setLoginTime(mContext, h.time, msg.getMsgTime());
if (h.mNickname != null) {
if (!isGroup && !TextUtils.equals(Constants.APP_EVERYONE, msg.getChatId()) && !TextUtils.equals(Constants.APP_MESH, msg.getChatId())) {
h.mNickname.setVisibility(View.GONE);
} else {
// group
h.mNickname.setVisibility(View.VISIBLE);
String name = msg.getUsername();
if (!TextUtils.isEmpty(tempAvatar.get(msg.getUserId()))) {
name = tempName.get(msg.getUserId());
}
h.mNickname.setText(name);
}
}
return convertView;
}
Aggregations