Java Code Examples for com.hyphenate.util.EMLog#e()
The following examples show how to use
com.hyphenate.util.EMLog#e() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EaseChatFragment.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
/** * send @ message, only support group chat message * @param content */ @SuppressWarnings("ConstantConditions") private void sendAtMessage(String content){ if(chatType != EaseConstant.CHATTYPE_GROUP){ EMLog.e(TAG, "only support group chat message"); return; } EMMessage message = EMMessage.createTxtSendMessage(content, toChatUsername); EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername); if(EMClient.getInstance().getCurrentUser().equals(group.getOwner()) && EaseAtMessageHelper.get().containsAtAll(content)){ message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL); }else { message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, EaseAtMessageHelper.get().atListToJsonArray(EaseAtMessageHelper.get().getAtMessageUsernames(content))); } sendMessage(message); }
Example 2
Source File: EaseCommonUtils.java From Social with Apache License 2.0 | 4 votes |
/** * 根据消息内容和消息类型获取消息内容提示 * * @param message * @param context * @return */ public static String getMessageDigest(EMMessage message, Context context) { String digest = ""; switch (message.getType()) { case LOCATION: // 位置消息 if (message.direct() == EMMessage.Direct.RECEIVE) { //从sdk中提到了ui中,使用更简单不犯错的获取string方法 // digest = EasyUtils.getAppResourceString(context, "location_recv"); digest = getString(context, R.string.location_recv); digest = String.format(digest, message.getFrom()); return digest; } else { // digest = EasyUtils.getAppResourceString(context, "location_prefix"); digest = getString(context, R.string.location_prefix); } break; case IMAGE: // 图片消息 digest = getString(context, R.string.picture); break; case VOICE:// 语音消息 digest = getString(context, R.string.voice_prefix); break; case VIDEO: // 视频消息 digest = getString(context, R.string.video); break; case TXT: // 文本消息 EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody(); /*if(((DemoHXSDKHelper)HXSDKHelper.getInstance()).isRobotMenuMessage(message)){ digest = ((DemoHXSDKHelper)HXSDKHelper.getInstance()).getRobotMenuMessageDigest(message); }else */if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VOICE_CALL, false)){ digest = getString(context, R.string.voice_call) + txtBody.getMessage(); }else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VIDEO_CALL, false)){ digest = getString(context, R.string.video_call) + txtBody.getMessage(); }else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ if(!TextUtils.isEmpty(txtBody.getMessage())){ digest = txtBody.getMessage(); }else{ digest = getString(context, R.string.dynamic_expression); } }else{ digest = txtBody.getMessage(); } break; case FILE: //普通文件消息 digest = getString(context, R.string.file); break; default: EMLog.e(TAG, "error, unknow type"); return ""; } return digest; }
Example 3
Source File: EaseShowBigImageActivity.java From Social with Apache License 2.0 | 4 votes |
/** * 下载图片 * * @param remoteFilePath */ private void downloadImage(final String remoteFilePath, final Map<String, String> headers) { 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() { 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 (EaseShowBigImageActivity.this.isFinishing() || EaseShowBigImageActivity.this.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 + "%"); } }); } }; EMClient.getInstance().chatManager().downloadFile(remoteFilePath, tempPath, headers, callback); }
Example 4
Source File: EaseChatRowVoicePlayClickListener.java From Social with Apache License 2.0 | 4 votes |
@Override public void onClick(View v) { String st = activity.getResources().getString(R.string.Is_download_voice_click_later); if (isPlaying) { if (playMsgId != null && playMsgId.equals(message.getMsgId())) { currentPlayListener.stopPlayVoice(); return; } currentPlayListener.stopPlayVoice(); } if (message.direct() == EMMessage.Direct.SEND) { // for sent msg, we will try to play the voice file directly playVoice(voiceBody.getLocalUrl()); } else { if (message.status() == EMMessage.Status.SUCCESS) { File file = new File(voiceBody.getLocalUrl()); if (file.exists() && file.isFile()) playVoice(voiceBody.getLocalUrl()); else EMLog.e(TAG, "file not exist"); } else if (message.status() == EMMessage.Status.INPROGRESS) { Toast.makeText(activity, st, Toast.LENGTH_SHORT).show(); } else if (message.status() == EMMessage.Status.FAIL) { Toast.makeText(activity, st, Toast.LENGTH_SHORT).show(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { EMClient.getInstance().chatManager().downloadAttachment(message); return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); adapter.notifyDataSetChanged(); } }.execute(); } } }
Example 5
Source File: EaseCommonUtils.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
/** * Get digest according message type and content * * @param message * @param context * @return */ public static String getMessageDigest(EMMessage message, Context context) { String digest = ""; switch (message.getType()) { case LOCATION: if (message.direct() == EMMessage.Direct.RECEIVE) { digest = getString(context, R.string.location_recv); digest = String.format(digest, message.getFrom()); return digest; } else { digest = getString(context, R.string.location_prefix); } break; case IMAGE: digest = getString(context, R.string.picture); break; case VOICE: digest = getString(context, R.string.voice_prefix); break; case VIDEO: digest = getString(context, R.string.video); break; case TXT: EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody(); if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VOICE_CALL, false)){ digest = getString(context, R.string.voice_call) + txtBody.getMessage(); }else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VIDEO_CALL, false)){ digest = getString(context, R.string.video_call) + txtBody.getMessage(); }else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ if(!TextUtils.isEmpty(txtBody.getMessage())){ digest = txtBody.getMessage(); }else{ digest = getString(context, R.string.dynamic_expression); } }else{ digest = txtBody.getMessage(); } break; case FILE: digest = getString(context, R.string.file); break; default: EMLog.e(TAG, "error, unknow type"); return ""; } return digest; }
Example 6
Source File: EaseChatRowVoicePlayClickListener.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
@Override public void onClick(View v) { String st = activity.getResources().getString(R.string.Is_download_voice_click_later); if (isPlaying) { if (playMsgId != null && playMsgId.equals(message.getMsgId())) { currentPlayListener.stopPlayVoice(); return; } currentPlayListener.stopPlayVoice(); } if (message.direct() == EMMessage.Direct.SEND) { // for sent msg, we will try to play the voice file directly playVoice(voiceBody.getLocalUrl()); } else { if (message.status() == EMMessage.Status.SUCCESS) { File file = new File(voiceBody.getLocalUrl()); if (file.exists() && file.isFile()) playVoice(voiceBody.getLocalUrl()); else EMLog.e(TAG, "file not exist"); } else if (message.status() == EMMessage.Status.INPROGRESS) { Toast.makeText(activity, st, Toast.LENGTH_SHORT).show(); } else if (message.status() == EMMessage.Status.FAIL) { Toast.makeText(activity, st, Toast.LENGTH_SHORT).show(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { EMClient.getInstance().chatManager().downloadAttachment(message); return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); adapter.notifyDataSetChanged(); } }.execute(); } } }
Example 7
Source File: EaseCommonUtils.java From nono-android with GNU General Public License v3.0 | 4 votes |
/** * 根据消息内容和消息类型获取消息内容提示 * * @param message * @param context * @return */ public static String getMessageDigest(EMMessage message, Context context) { String digest = ""; switch (message.getType()) { case LOCATION: // 位置消息 if (message.direct() == EMMessage.Direct.RECEIVE) { //从sdk中提到了ui中,使用更简单不犯错的获取string方法 // digest = EasyUtils.getAppResourceString(context, "location_recv"); digest = getString(context, R.string.location_recv); digest = String.format(digest, message.getFrom()); return digest; } else { // digest = EasyUtils.getAppResourceString(context, "location_prefix"); digest = getString(context, R.string.location_prefix); } break; case IMAGE: // 图片消息 digest = getString(context, R.string.picture); break; case VOICE:// 语音消息 digest = getString(context, R.string.voice_prefix); break; case VIDEO: // 视频消息 digest = getString(context, R.string.video); break; case TXT: // 文本消息 EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody(); /*if(((DemoHXSDKHelper)HXSDKHelper.getInstance()).isRobotMenuMessage(message)){ digest = ((DemoHXSDKHelper)HXSDKHelper.getInstance()).getRobotMenuMessageDigest(message); }else */if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_VOICE_CALL, false)){ digest = getString(context, R.string.voice_call) + txtBody.getMessage(); }else if(message.getBooleanAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, false)){ if(!TextUtils.isEmpty(txtBody.getMessage())){ digest = txtBody.getMessage(); }else{ digest = getString(context, R.string.dynamic_expression); } }else{ digest = txtBody.getMessage(); } break; case FILE: //普通文件消息 digest = getString(context, R.string.file); break; default: EMLog.e(TAG, "error, unknow type"); return ""; } return digest; }
Example 8
Source File: EaseChatRowVoicePlayClickListener.java From nono-android with GNU General Public License v3.0 | 4 votes |
@Override public void onClick(View v) { String st = activity.getResources().getString(R.string.Is_download_voice_click_later); if (isPlaying) { if (playMsgId != null && playMsgId.equals(message.getMsgId())) { currentPlayListener.stopPlayVoice(); return; } currentPlayListener.stopPlayVoice(); } if (message.direct() == EMMessage.Direct.SEND) { // for sent msg, we will try to play the voice file directly playVoice(voiceBody.getLocalUrl()); } else { if (message.status() == EMMessage.Status.SUCCESS) { File file = new File(voiceBody.getLocalUrl()); if (file.exists() && file.isFile()) playVoice(voiceBody.getLocalUrl()); else EMLog.e(TAG, "file not exist"); } else if (message.status() == EMMessage.Status.INPROGRESS) { Toast.makeText(activity, st, Toast.LENGTH_SHORT).show(); } else if (message.status() == EMMessage.Status.FAIL) { Toast.makeText(activity, st, Toast.LENGTH_SHORT).show(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { EMClient.getInstance().chatManager().downloadAttachment(message); return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); adapter.notifyDataSetChanged(); } }.execute(); } } }