use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class FinalUserDataBase method getChatMsgAddContact.
/**
* Add buddy request information after the new one
*/
public ChatMsg getChatMsgAddContact() {
String sql = "select * from " + TableField.TABLE_CHAT_EVENT + " where " + TableField.FIELD_CHAT_SYSTEM + "=1 and " + TableField.FIELD_CHAT_TYPE + "=0 and " + TableField.FIELD_CHAT_HIDDEN + "=1 " + " order by " + TableField.FIELD_CHAT_MSGTIME + " desc " + " limit " + 0 + "," + 1;
Cursor cursor = db.rawQuery(sql, null);
ChatMsg msg = null;
if (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.setAgree(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_AGREE)) == 1);
msg.setMessageId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA1)));
msg.setShareFriendName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA2)));
msg.setGroupImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_GROUP_IMAGE)));
msg.setMsgTypeInt(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_OBJECT)));
}
cursor.close();
return msg;
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class MsgAddContactListUI method onItemLongClick.
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
MyDialogFragment mdf = new MyDialogFragment(MyDialogFragment.DIALOG_LIST, R.array.delete_chat_array);
mdf.setItemClickCallback(new MyDialogFragment.ItemClickCallback() {
@Override
public void itemClickCallback(int which) {
ChatMsg msg = mList.get(position);
FinalUserDataBase.getInstance().deleteChatEventAddContactByMessageId(msg.getMessageId());
MyToast.showToast(MsgAddContactListUI.this, getString(R.string.delete_success));
mList.remove(position);
mAdapter.updateList(mList);
}
});
mdf.show(getSupportFragmentManager(), "mdf");
return true;
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class ScanLargePic method onLongClickCallback.
@Override
public void onLongClickCallback(final String oldPath) {
LayoutInflater factory = LayoutInflater.from(this);
final View view = factory.inflate(R.layout.large_pic_diaog, null);
saveToSD = (RelativeLayout) view.findViewById(R.id.save_to_phone_rela);
identifyQr = (RelativeLayout) view.findViewById(R.id.zxing_rela);
sendToFriend = (RelativeLayout) view.findViewById(R.id.send_to_friend);
identifyQr.setVisibility(View.GONE);
AlertDialog.Builder builder = new AlertDialog.Builder(ScanLargePic.this);
builder.setView(view);
final AlertDialog dialog = builder.create();
dialog.show();
// Set other area for Dialog click screen disappeared
dialog.setCanceledOnTouchOutside(true);
saveToSD.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String qrPath = BitmapUtils.saveBitmapFile(getApplicationContext(), oldPath);
if (!TextUtils.isEmpty(qrPath)) {
showToast(getString(R.string.photo_save_dir, qrPath));
dialog.dismiss();
}
}
});
sendToFriend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ArrayList<ChatMsg> list = new ArrayList<>();
ChatMsg msg = new ChatMsg();
msg.setType(1);
msg.setContent(oldPath);
msg.setLocalUrl(oldPath);
msg.parseUserBaseVo(NextApplication.myInfo);
list.add(msg);
Intent intent = new Intent(ScanLargePic.this, ContactSelectedUI.class);
intent.putExtra("msglist", list);
startActivity(intent);
Utils.openNewActivityAnim(ScanLargePic.this, false);
dialog.dismiss();
}
});
/*If open thread scanning images is qr code*/
new Thread(new Runnable() {
@Override
public void run() {
Result result = scanningImage(oldPath);
if (result != null) {
Message m = mHandler.obtainMessage();
ScanImageVo vo = new ScanImageVo();
vo.dialog = dialog;
vo.oldPath = oldPath;
vo.scanResult = result.toString();
vo.currentIndex = vpPhotos.getCurrentItem();
m.what = 0;
m.obj = vo;
mHandler.sendMessage(m);
}
}
}).start();
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class XmppService method parseNormalChat.
/**
* Normal chat processing
*/
private ChatMsg parseNormalChat(Message msg, boolean isSystem) {
if (!TextUtils.isEmpty(msg.getBody())) {
try {
String content = null;
ChatMsg chatmsg = parseBody(msg);
chatmsg.setMsgType(msg.getMsgtype());
if (!isSystem && !checkChatType(chatmsg.getType())) {
// Is not the system news, if not compatible message directly to ignore
chatmsg.setType(50000);
}
try {
MySharedPrefs.writeBoolean(NextApplication.mContext, MySharedPrefs.FILE_USER, MySharedPrefs.IS_MASK_MSG + NextApplication.myInfo.getLocalId() + "_" + chatmsg.getChatId(), chatmsg.getGroupMask());
} catch (Exception e) {
e.printStackTrace();
}
if (chatmsg.getType() == 10000) {
// Offline message set
new Thread(new HandleOfflineMsgList(chatmsg, MsgType.normalchat)).start();
return chatmsg;
}
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 // System prompt message, such as greeting strangers than 5 tips will return system
500:
chatmsg.setType(12);
break;
case // Not compatible with high version of the news
50000:
chatmsg.setContent(chatmsg.getMsgName());
break;
}
if (isSystem) {
// The system prompt
FinalUserDataBase.getInstance().saveChatMsg(chatmsg, chatmsg.getUserId(), chatmsg.getUsername(), chatmsg.getUserImage(), false);
} else {
FinalUserDataBase.getInstance().saveChatMsg(chatmsg, chatmsg.getUserId(), chatmsg.getUsername(), chatmsg.getUserImage());
}
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;
}
use of com.lingtuan.firefly.vo.ChatMsg in project SmartMesh_Android by SmartMeshFoundation.
the class XmppService method parseSuperGroupChat.
/**
* Group chat with
*/
private ChatMsg parseSuperGroupChat(Message msg, boolean isGroupSystem) {
if (!TextUtils.isEmpty(msg.getBody())) {
try {
String content = null;
ChatMsg chatmsg = parseBody(msg);
chatmsg.setMsgType(msg.getMsgtype());
if (// Offline message
chatmsg.getType() == 10000) {
new Thread(new HandleOfflineMsgList(chatmsg, MsgType.super_groupchat)).start();
return chatmsg;
} else if (!isGroupSystem) {
// The system information
// Group information for the type on the basis of 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 (!isGroupSystem) {
// Is not a group of notice
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;
}
} else {
// Is a group of notification
chatmsg.setDismissGroup(chatmsg.getType() == 109);
chatmsg.setKickGroup(chatmsg.getType() == 108);
if (chatmsg.getType() == 108) {
chatmsg.setType(12);
} else if (chatmsg.getType() == 109) {
chatmsg.setType(12);
} else if (chatmsg.getType() == 1000) {
chatmsg.setType(12);
}
try {
MySharedPrefs.writeBoolean(NextApplication.mContext, MySharedPrefs.FILE_USER, MySharedPrefs.IS_MASK_MSG + NextApplication.myInfo.getLocalId() + "_" + chatmsg.getChatId(), chatmsg.getGroupMask());
} catch (Exception e) {
e.printStackTrace();
}
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);
}
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(), chatmsg.getGroupImage(), false);
} else {
// Is not the system information is normal
FinalUserDataBase.getInstance().saveChatMsg(chatmsg, chatmsg.getChatId(), chatmsg.getGroupName(), chatmsg.getGroupImage());
}
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;
}
Aggregations