Search in sources :

Example 16 with EMMessage

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

the class EaseShowNormalFileActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ease_activity_show_file);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    final EMMessage message = getIntent().getParcelableExtra("msg");
    if (!(message.getBody() instanceof EMFileMessageBody)) {
        Toast.makeText(EaseShowNormalFileActivity.this, "Unsupported message body", Toast.LENGTH_SHORT).show();
        finish();
        return;
    }
    final File file = new File(((EMFileMessageBody) message.getBody()).getLocalUrl());
    message.setMessageStatusCallback(new EMCallBack() {

        @Override
        public void onSuccess() {
            runOnUiThread(new Runnable() {

                public void run() {
                    FileUtils.openFile(file, EaseShowNormalFileActivity.this);
                    finish();
                }
            });
        }

        @Override
        public void onError(int code, String error) {
            runOnUiThread(new Runnable() {

                public void run() {
                    if (file != null && file.exists() && file.isFile())
                        file.delete();
                    String str4 = getResources().getString(R.string.Failed_to_download_file);
                    Toast.makeText(EaseShowNormalFileActivity.this, str4 + message, Toast.LENGTH_SHORT).show();
                    finish();
                }
            });
        }

        @Override
        public void onProgress(final int progress, String status) {
            runOnUiThread(new Runnable() {

                public void run() {
                    progressBar.setProgress(progress);
                }
            });
        }
    });
    EMClient.getInstance().chatManager().downloadAttachment(message);
}
Also used : EMCallBack(com.hyphenate.EMCallBack) EMFileMessageBody(com.hyphenate.chat.EMFileMessageBody) File(java.io.File) EMMessage(com.hyphenate.chat.EMMessage)

Example 17 with EMMessage

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

the class EaseCommonUtils method createExpressionMessage.

public static EMMessage createExpressionMessage(String toChatUsername, String expressioName, String identityCode) {
    EMMessage message = EMMessage.createTxtSendMessage("[" + expressioName + "]", toChatUsername);
    if (identityCode != null) {
        message.setAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, identityCode);
    }
    message.setAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, true);
    return message;
}
Also used : EMMessage(com.hyphenate.chat.EMMessage)

Example 18 with EMMessage

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

the class EaseChatFragment method sendBigExpressionMessage.

protected void sendBigExpressionMessage(String name, String identityCode) {
    EMMessage message = EaseCommonUtils.createExpressionMessage(toChatUsername, name, identityCode);
    sendMessage(message);
}
Also used : EMMessage(com.hyphenate.chat.EMMessage)

Example 19 with EMMessage

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

the class EaseChatFragment method sendImageMessage.

protected void sendImageMessage(String imagePath) {
    EMMessage message = EMMessage.createImageSendMessage(imagePath, false, toChatUsername);
    sendMessage(message);
}
Also used : EMMessage(com.hyphenate.chat.EMMessage)

Example 20 with EMMessage

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

the class EaseChatFragment method sendLocationMessage.

protected void sendLocationMessage(double latitude, double longitude, String locationAddress) {
    EMMessage message = EMMessage.createLocationSendMessage(latitude, longitude, locationAddress, toChatUsername);
    sendMessage(message);
}
Also used : EMMessage(com.hyphenate.chat.EMMessage)

Aggregations

EMMessage (com.hyphenate.chat.EMMessage)24 File (java.io.File)4 EMCallBack (com.hyphenate.EMCallBack)3 SuppressLint (android.annotation.SuppressLint)2 EMCmdMessageBody (com.hyphenate.chat.EMCmdMessageBody)2 EMGroup (com.hyphenate.chat.EMGroup)2 EMTextMessageBody (com.hyphenate.chat.EMTextMessageBody)2 EMAMessage (com.hyphenate.chat.adapter.message.EMAMessage)2 EaseAvatarOptions (com.hyphenate.easeui.domain.EaseAvatarOptions)2 EaseImageView (com.hyphenate.easeui.widget.EaseImageView)2 Date (java.util.Date)2 ProgressDialog (android.app.ProgressDialog)1 Intent (android.content.Intent)1 DisplayMetrics (android.util.DisplayMetrics)1 TextView (android.widget.TextView)1 EMChatRoom (com.hyphenate.chat.EMChatRoom)1 EMConversation (com.hyphenate.chat.EMConversation)1 EMFileMessageBody (com.hyphenate.chat.EMFileMessageBody)1 EMImageMessageBody (com.hyphenate.chat.EMImageMessageBody)1 EMVideoMessageBody (com.hyphenate.chat.EMVideoMessageBody)1