@Override void clearConversation() { super.clearConversation(); this.messageDB.clearConversation(); if (secret) { NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(this.receiver, CLEAR_SECRET_MESSAGES); nc.postNotification(notification); } else { NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(this.receiver, CLEAR_MESSAGES); nc.postNotification(notification); } }
@Override void clearConversation() { super.clearConversation(); CustomerMessageDB db = CustomerMessageDB.getInstance(); db.clearCoversation(this.storeID); NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(this.storeID, CLEAR_MESSAGES); nc.postNotification(notification); } }
@Override protected void onDestroy() { super.onDestroy(); IMService im = IMService.getInstance(); im.removeObserver(this); im.removePeerObserver(this); im.removeGroupObserver(this); im.removeSystemObserver(this); NotificationCenter nc = NotificationCenter.defaultCenter(); nc.removeObserver(this); Log.i(TAG, "message list activity destroyed"); }
@Override protected void clearConversation() { super.clearConversation(); GroupMessageDB db = GroupMessageDB.getInstance(); db.clearCoversation(this.groupID); NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(this.receiver, CLEAR_MESSAGES); nc.postNotification(notification); }
@Override protected void onDestroy() { super.onDestroy(); Log.i(TAG, "peer message activity destory"); if (secret) { NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(this.receiver, CLEAR_SECRET_NEW_MESSAGES); nc.postNotification(notification); } else { NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(this.receiver, CLEAR_NEW_MESSAGES); nc.postNotification(notification); } PeerOutbox.getInstance().removeObserver(this); IMService.getInstance().removeObserver(this); IMService.getInstance().removePeerObserver(this); FileDownloader.getInstance().removeObserver(this); }
@Override protected void onDestroy() { super.onDestroy(); Log.i(TAG, "peer message activity destory"); NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(this.groupID, CLEAR_NEW_MESSAGES); nc.postNotification(notification); GroupOutbox.getInstance().removeObserver(this); IMService.getInstance().removeObserver(this); IMService.getInstance().removeGroupObserver(this); FileDownloader.getInstance().removeObserver(this); }
@Override protected void onDestroy() { super.onDestroy(); Log.i(TAG, "peer message activity destory"); NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(this.storeID, CLEAR_NEW_MESSAGES); nc.postNotification(notification); CustomerOutbox.getInstance().removeObserver(this); IMService.getInstance().removeObserver(this); IMService.getInstance().removeCustomerServiceObserver(this); FileDownloader.getInstance().removeObserver(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(TAG, "main activity create..."); setContentView(R.layout.activity_conversation); Intent intent = getIntent(); currentUID = intent.getLongExtra("current_uid", 0); if (currentUID == 0) { Log.e(TAG, "current uid is 0"); return; } IMService im = IMService.getInstance(); im.addObserver(this); im.addPeerObserver(this); im.addGroupObserver(this); im.addSystemObserver(this); loadConversations(); initWidget(); NotificationCenter nc = NotificationCenter.defaultCenter(); nc.addObserver(this, PeerMessageActivity.SEND_MESSAGE_NAME); nc.addObserver(this, PeerMessageActivity.CLEAR_MESSAGES); nc.addObserver(this, GroupMessageActivity.SEND_MESSAGE_NAME); nc.addObserver(this, GroupMessageActivity.CLEAR_MESSAGES); }
@Override protected boolean sendMessage(IMessage imsg) { boolean r = true; if (imsg.content.getType() == MessageContent.MessageType.MESSAGE_AUDIO) { GroupOutbox ob = GroupOutbox.getInstance(); Audio audio = (Audio)imsg.content; imsg.setUploading(true); ob.uploadAudio(imsg, FileCache.getInstance().getCachedFilePath(audio.url)); } else if (imsg.content.getType() == MessageContent.MessageType.MESSAGE_IMAGE) { Image image = (Image)imsg.content; //prefix:"file:" String path = image.url.substring(5); imsg.setUploading(true); GroupOutbox.getInstance().uploadImage(imsg, path); } else { IMMessage msg = new IMMessage(); msg.sender = imsg.sender; msg.receiver = imsg.receiver; msg.content = imsg.content.getRaw(); msg.msgLocalID = imsg.msgLocalID; IMService im = IMService.getInstance(); r = im.sendGroupMessage(msg); } NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(imsg, SEND_MESSAGE_NAME); nc.postNotification(notification); return r; }
r = im.sendCustomerMessage(msg); NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(imsg, SEND_MESSAGE_NAME); nc.postNotification(notification);
NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(imsg, SEND_SECRET_MESSAGE_NAME); nc.postNotification(notification); } else { NotificationCenter nc = NotificationCenter.defaultCenter(); Notification notification = new Notification(imsg, SEND_MESSAGE_NAME); nc.postNotification(notification);