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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations