use of com.hyphenate.chat.EMMessage in project SmartCampus by Vegen.
the class EaseChatFragment method sendVideoMessage.
protected void sendVideoMessage(String videoPath, String thumbPath, int videoLength) {
EMMessage message = EMMessage.createVideoSendMessage(videoPath, thumbPath, videoLength, toChatUsername);
sendMessage(message);
}
use of com.hyphenate.chat.EMMessage in project SmartCampus by Vegen.
the class EaseShowBigImageActivity method downloadImage.
/**
* download image
*
* @param remoteFilePath
*/
@SuppressLint("NewApi")
private void downloadImage(final String msgId) {
EMLog.e(TAG, "download with messageId: " + msgId);
String str1 = getResources().getString(R.string.Download_the_pictures);
pd = new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setCanceledOnTouchOutside(false);
pd.setMessage(str1);
pd.show();
File temp = new File(localFilePath);
final String tempPath = temp.getParent() + "/temp_" + temp.getName();
final EMCallBack callback = new EMCallBack() {
public void onSuccess() {
EMLog.e(TAG, "onSuccess");
runOnUiThread(new Runnable() {
@Override
public void run() {
new File(tempPath).renameTo(new File(localFilePath));
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int screenWidth = metrics.widthPixels;
int screenHeight = metrics.heightPixels;
bitmap = ImageUtils.decodeScaleImage(localFilePath, screenWidth, screenHeight);
if (bitmap == null) {
image.setImageResource(default_res);
} else {
image.setImageBitmap(bitmap);
EaseImageCache.getInstance().put(localFilePath, bitmap);
isDownloaded = true;
}
if (isFinishing() || isDestroyed()) {
return;
}
if (pd != null) {
pd.dismiss();
}
}
});
}
public void onError(int error, String msg) {
EMLog.e(TAG, "offline file transfer error:" + msg);
File file = new File(tempPath);
if (file.exists() && file.isFile()) {
file.delete();
}
runOnUiThread(new Runnable() {
@Override
public void run() {
if (EaseShowBigImageActivity.this.isFinishing() || EaseShowBigImageActivity.this.isDestroyed()) {
return;
}
image.setImageResource(default_res);
pd.dismiss();
}
});
}
public void onProgress(final int progress, String status) {
EMLog.d(TAG, "Progress: " + progress);
final String str2 = getResources().getString(R.string.Download_the_pictures_new);
runOnUiThread(new Runnable() {
@Override
public void run() {
if (EaseShowBigImageActivity.this.isFinishing() || EaseShowBigImageActivity.this.isDestroyed()) {
return;
}
pd.setMessage(str2 + progress + "%");
}
});
}
};
EMMessage msg = EMClient.getInstance().chatManager().getMessage(msgId);
msg.setMessageStatusCallback(callback);
EMLog.e(TAG, "downloadAttachement");
EMClient.getInstance().chatManager().downloadAttachment(msg);
}
use of com.hyphenate.chat.EMMessage in project SmartCampus by Vegen.
the class EaseShowVideoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.ease_showvideo_activity);
loadingLayout = (RelativeLayout) findViewById(R.id.loading_layout);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
final EMMessage message = getIntent().getParcelableExtra("msg");
if (!(message.getBody() instanceof EMVideoMessageBody)) {
Toast.makeText(EaseShowVideoActivity.this, "Unsupported message body", Toast.LENGTH_SHORT).show();
finish();
return;
}
EMVideoMessageBody messageBody = (EMVideoMessageBody) message.getBody();
localFilePath = messageBody.getLocalUrl();
if (localFilePath != null && new File(localFilePath).exists()) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(localFilePath)), "video/mp4");
startActivity(intent);
finish();
} else {
EMLog.d(TAG, "download remote video file");
downloadVideo(message);
}
}
use of com.hyphenate.chat.EMMessage in project SmartCampus by Vegen.
the class EaseDingMessageHelperTest method createDingAckMessage.
private EMMessage createDingAckMessage(String conversationId, String originalMsgId, String from) {
EMAMessage _msg = EMAMessage.createSendMessage(from, "", null, EMMessage.ChatType.Chat.ordinal());
EMMessage msg = new EMMessage(_msg);
msg.setAttribute(KEY_CONVERSATION_ID, conversationId);
msg.setAttribute(KEY_DING_ACK, true);
msg.addBody(new EMCmdMessageBody(originalMsgId));
return msg;
}
Aggregations