Search in sources :

Example 1 with EMNormalFileMessageBody

use of com.hyphenate.chat.EMNormalFileMessageBody in project SmartCampus by Vegen.

the class EaseChatFilePresenter method onBubbleClick.

@Override
public void onBubbleClick(EMMessage message) {
    EMNormalFileMessageBody fileMessageBody = (EMNormalFileMessageBody) message.getBody();
    String filePath = fileMessageBody.getLocalUrl();
    File file = new File(filePath);
    if (file.exists()) {
        // open files if it exist
        FileUtils.openFile(file, (Activity) getContext());
    } else {
        // download the file
        getContext().startActivity(new Intent(getContext(), EaseShowNormalFileActivity.class).putExtra("msg", message));
    }
    if (message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked() && message.getChatType() == EMMessage.ChatType.Chat) {
        try {
            EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
        } catch (HyphenateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Also used : HyphenateException(com.hyphenate.exceptions.HyphenateException) EMNormalFileMessageBody(com.hyphenate.chat.EMNormalFileMessageBody) Intent(android.content.Intent) File(java.io.File) EaseChatRowFile(com.hyphenate.easeui.widget.chatrow.EaseChatRowFile)

Aggregations

Intent (android.content.Intent)1 EMNormalFileMessageBody (com.hyphenate.chat.EMNormalFileMessageBody)1 EaseChatRowFile (com.hyphenate.easeui.widget.chatrow.EaseChatRowFile)1 HyphenateException (com.hyphenate.exceptions.HyphenateException)1 File (java.io.File)1