com.hyphenate.exceptions.HyphenateException Java Examples
The following examples show how to use
com.hyphenate.exceptions.HyphenateException.
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: RecommendGroupDialogActivity.java From Social with Apache License 2.0 | 6 votes |
private void joinGroup(){ //OkhttpUtil.joinGroup(handler,group.id, SharedPreferenceUtil.getUserName()); //直接加入群组 new Thread(new Runnable() { @Override public void run() { try { //如果群开群是自由加入的,即group.isMembersOnly()为false,直接join EMClient.getInstance().groupManager().joinGroup(group.hx_group_id);//需异步处理 //添加服务器群组成员记录 OkhttpUtil.joinGroup(handler, group.id,SharedPreferenceUtil.getUserName()); }catch (HyphenateException e){ e.printStackTrace(); } } }).start(); }
Example #2
Source File: HxSdkHelper.java From FamilyChat with Apache License 2.0 | 6 votes |
/** * 注册方法 * * @param phone 手机号 * @param pwd 密码 * @param callBack 回调【注意回调会在子线程中】 */ public void regist(final String phone, final String pwd, final FCCallBack callBack) { ThreadManager.getInstance().addNewRunnable(new Runnable() { @Override public void run() { try { EMClient.getInstance().createAccount(phone, pwd); if (callBack != null) callBack.onSuccess(null); } catch (HyphenateException e) { KLog.e("HxSdk regist from server fail : hxErrCode = " + e.getErrorCode() + " , msg = " + e.getMessage()); if (callBack != null) callBack.onFail(FCError.REGIST_FAIL, FCError.getErrorMsgIdFromCode(e.getErrorCode())); } } }); }
Example #3
Source File: AddFriendPresenter.java From FamilyChat with Apache License 2.0 | 6 votes |
public void sendRequest(String phone) { if (StringUtil.isEmpty(phone)) { mAddFriendView.phoneEmptyWarning(); return; } if (!PhoneUtils.isMobileNO(phone)) { mAddFriendView.phoneErrorWarning(); return; } try { HxSdkHelper.getInstance().addFriend(phone); mAddFriendView.sendRequestSuccess(); } catch (HyphenateException e) { KLog.e("AddFriendActivity sendRequest fail:" + e.toString()); mAddFriendView.sendRequestFail(FCError.ADD_FRIEND_FAIL, FCError.getErrorMsgIdFromCode(e.getErrorCode())); } }
Example #4
Source File: EaseChatRowFile.java From Social with Apache License 2.0 | 6 votes |
@Override protected void onBubbleClick() { String filePath = fileMessageBody.getLocalUrl(); File file = new File(filePath); if (file != null && file.exists()) { // 文件存在,直接打开 FileUtils.openFile(file, (Activity) context); } else { // 下载 context.startActivity(new Intent(context, EaseShowNormalFileActivity.class).putExtra("msgbody", message.getBody())); } if (message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked() && message.getChatType() == ChatType.Chat) { try { EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId()); } catch (HyphenateException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Example #5
Source File: EaseChatRowFile.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override protected void onBubbleClick() { String filePath = fileMessageBody.getLocalUrl(); File file = new File(filePath); if (file.exists()) { // open files if it exist FileUtils.openFile(file, (Activity) context); } else { // download the file context.startActivity(new Intent(context, EaseShowNormalFileActivity.class).putExtra("msgbody", message.getBody())); } if (message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked() && message.getChatType() == ChatType.Chat) { try { EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId()); } catch (HyphenateException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Example #6
Source File: GroupMemberActivity.java From Social with Apache License 2.0 | 5 votes |
private void handleKickGroupMember(Message msg){ String result = msg.obj.toString(); Log.d("NearbyFragment", result); Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create(); KickGroupMemberRoot root = gson.fromJson(result, KickGroupMemberRoot.class); if(root==null){ //new Dialog(this,"错误","链接服务器失败").show(); Toast.makeText(this,"服务器繁忙,请重试",Toast.LENGTH_LONG).show(); return ; } if (root.success == false){ new Dialog(this,"错误",root.message).show(); } //踢人 new Thread(new Runnable() { @Override public void run() { try { EMClient.getInstance().groupManager().removeUserFromGroup(hx_group_id,kicked_username );//需异步处理 }catch (HyphenateException e){ e.printStackTrace(); } } }).start(); getGroupMember(); }
Example #7
Source File: HxSdkHelper.java From FamilyChat with Apache License 2.0 | 5 votes |
/** * 从环信服务器拉取好友列表【仅包含账号】 * * @param callBack 回调 */ public void asyncUserListFromServer(final FCCallBack<List<String>> callBack) { if (mHasAsyncUserList) { KLog.i("HxSdk already has asynced user from server."); if (callBack != null) callBack.onSuccess(null); return; } ThreadManager.getInstance().addNewRunnable(new Runnable() { @Override public void run() { try { List<String> userList = EMClient.getInstance().contactManager().getAllContactsFromServer(); KLog.i("HxSdk async user from server : " + userList); mHasAsyncUserList = true; if (callBack != null) callBack.onSuccess(userList); } catch (HyphenateException e) { KLog.e("HxSdk async user from server fail : hxErrCode = " + e.getErrorCode() + " , msg = " + e.getMessage()); if (callBack != null) callBack.onFail(FCError.ASYNC_HXUSER_FAIL, FCError.getErrorMsgIdFromCode(e.getErrorCode())); } } }); }
Example #8
Source File: HxCallBaseActivity.java From FamilyChat with Apache License 2.0 | 5 votes |
/** * 切换静音开关 */ protected void switchMuteMode(boolean isMute) { try { if (isMute) HxCallHelper.getInstance().pauseVoiceTransfer(); else HxCallHelper.getInstance().resumeVoiceTransfer(); } catch (HyphenateException e) { KLog.e("HxCallBaseActivity switchMuteMode fail:" + e.toString()); } }
Example #9
Source File: EaseChatRowText.java From nono-android with GNU General Public License v3.0 | 5 votes |
protected void handleTextMessage() { if (message.direct() == EMMessage.Direct.SEND) { setMessageSendCallback(); switch (message.status()) { case CREATE: progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); // 发送消息 // sendMsgInBackground(message); break; case SUCCESS: // 发送成功 progressBar.setVisibility(View.GONE); statusView.setVisibility(View.GONE); break; case FAIL: // 发送失败 progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); break; case INPROGRESS: // 发送中 progressBar.setVisibility(View.VISIBLE); statusView.setVisibility(View.GONE); break; default: break; } }else{ if(!message.isAcked() && message.getChatType() == ChatType.Chat){ try { EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId()); } catch (HyphenateException e) { e.printStackTrace(); } } } }
Example #10
Source File: EaseChatRowText.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
protected void handleTextMessage() { if (message.direct() == EMMessage.Direct.SEND) { setMessageSendCallback(); switch (message.status()) { case CREATE: progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); break; case SUCCESS: progressBar.setVisibility(View.GONE); statusView.setVisibility(View.GONE); break; case FAIL: progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); break; case INPROGRESS: progressBar.setVisibility(View.VISIBLE); statusView.setVisibility(View.GONE); break; default: break; } }else{ if(!message.isAcked() && message.getChatType() == ChatType.Chat){ try { EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId()); } catch (HyphenateException e) { e.printStackTrace(); } } } }
Example #11
Source File: EaseChatRowLocation.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override protected void onSetUpView() { locBody = (EMLocationMessageBody) message.getBody(); locationView.setText(locBody.getAddress()); // handle sending message if (message.direct() == EMMessage.Direct.SEND) { setMessageSendCallback(); switch (message.status()) { case CREATE: progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); break; case SUCCESS: progressBar.setVisibility(View.GONE); statusView.setVisibility(View.GONE); break; case FAIL: progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); break; case INPROGRESS: progressBar.setVisibility(View.VISIBLE); statusView.setVisibility(View.GONE); break; default: break; } }else{ if(!message.isAcked() && message.getChatType() == ChatType.Chat){ try { EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId()); } catch (HyphenateException e) { e.printStackTrace(); } } } }
Example #12
Source File: EaseContactListFragment.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
/** * move user to blacklist */ protected void moveToBlacklist(final String username){ final ProgressDialog pd = new ProgressDialog(getActivity()); String st1 = getResources().getString(R.string.Is_moved_into_blacklist); final String st2 = getResources().getString(R.string.Move_into_blacklist_success); final String st3 = getResources().getString(R.string.Move_into_blacklist_failure); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { //move to blacklist EMClient.getInstance().contactManager().addUserToBlackList(username,false); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show(); refresh(); } }); } catch (HyphenateException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show(); } }); } } }).start(); }
Example #13
Source File: EaseChatRowText.java From Social with Apache License 2.0 | 5 votes |
protected void handleTextMessage() { if (message.direct() == EMMessage.Direct.SEND) { setMessageSendCallback(); switch (message.status()) { case CREATE: progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); // 发送消息 // sendMsgInBackground(message); break; case SUCCESS: // 发送成功 progressBar.setVisibility(View.GONE); statusView.setVisibility(View.GONE); break; case FAIL: // 发送失败 progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); break; case INPROGRESS: // 发送中 progressBar.setVisibility(View.VISIBLE); statusView.setVisibility(View.GONE); break; default: break; } }else{ if(!message.isAcked() && message.getChatType() == ChatType.Chat){ try { EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId()); } catch (HyphenateException e) { e.printStackTrace(); } } } }
Example #14
Source File: EaseChatRowLocation.java From Social with Apache License 2.0 | 5 votes |
@Override protected void onSetUpView() { locBody = (EMLocationMessageBody) message.getBody(); locationView.setText(locBody.getAddress()); // deal with send message if (message.direct() == EMMessage.Direct.SEND) { setMessageSendCallback(); switch (message.status()) { case CREATE: progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); // 发送消息 // sendMsgInBackground(message); break; case SUCCESS: // 发送成功 progressBar.setVisibility(View.GONE); statusView.setVisibility(View.GONE); break; case FAIL: // 发送失败 progressBar.setVisibility(View.GONE); statusView.setVisibility(View.VISIBLE); break; case INPROGRESS: // 发送中 progressBar.setVisibility(View.VISIBLE); statusView.setVisibility(View.GONE); break; default: break; } }else{ if(!message.isAcked() && message.getChatType() == ChatType.Chat){ try { EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId()); } catch (HyphenateException e) { e.printStackTrace(); } } } }
Example #15
Source File: EaseContactListFragment.java From Social with Apache License 2.0 | 5 votes |
/** * 把user移入到黑名单 */ protected void moveToBlacklist(final String username){ final ProgressDialog pd = new ProgressDialog(getActivity()); String st1 = getResources().getString(R.string.Is_moved_into_blacklist); final String st2 = getResources().getString(R.string.Move_into_blacklist_success); final String st3 = getResources().getString(R.string.Move_into_blacklist_failure); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { //加入到黑名单 EMClient.getInstance().contactManager().addUserToBlackList(username,false); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2, 0).show(); refresh(); } }); } catch (HyphenateException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st3, 0).show(); } }); } } }).start(); }
Example #16
Source File: GroupDataActivity.java From Social with Apache License 2.0 | 5 votes |
private void handleDeleteGroup(Message msg){ String result = msg.obj.toString(); Log.d("NearbyFragment", result); gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create(); root = gson.fromJson(result, Root.class); if(root==null){ //new Dialog(this,"错误","链接服务器失败").show(); Toast.makeText(this,"服务器繁忙,请重试",Toast.LENGTH_LONG).show(); return ; } if (root.success == false){ new Dialog(this,"错误",root.message).show(); } new Thread(new Runnable() { @Override public void run() { try { EMClient.getInstance().groupManager().destroyGroup(hx_group_id);//需异步处理 }catch (HyphenateException e){ e.printStackTrace(); } } }).start(); Dialog dialog = new Dialog(this,"Tips","删除成功"); dialog.setOnAcceptButtonClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent("com.allever.social.refresh_group_list"); sendBroadcast(intent); GroupDataActivity.this.finish(); } }); dialog.show(); }
Example #17
Source File: GroupDataActivity.java From Social with Apache License 2.0 | 4 votes |
private void handleDropGroup(Message msg){ String result = msg.obj.toString(); Log.d("NearbyFragment", result); gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create(); root = gson.fromJson(result, Root.class); if(root==null){ //new Dialog(this,"错误","链接服务器失败").show(); Toast.makeText(this,"服务器繁忙,请重试",Toast.LENGTH_LONG).show(); return ; } if (root.success == false){ new Dialog(this,"错误",root.message).show(); } //退出环信群组 new Thread(new Runnable() { @Override public void run() { try { EMClient.getInstance().groupManager().leaveGroup(hx_group_id);//需异步处理 }catch (HyphenateException e){ e.printStackTrace(); } } }).start(); Dialog dialog = new Dialog(this,"Tips","退群成功"); dialog.setOnAcceptButtonClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent("com.allever.social.refresh_group_list"); sendBroadcast(intent); btn_join.setVisibility(View.VISIBLE); btn_drop.setVisibility(View.INVISIBLE); } }); dialog.show(); }
Example #18
Source File: HxCallHelper.java From FamilyChat with Apache License 2.0 | 4 votes |
/** * 暂停语音传输 * 【用于静音】 */ public void pauseVoiceTransfer() throws HyphenateException { EMClient.getInstance().callManager().pauseVoiceTransfer(); }
Example #19
Source File: HxCallHelper.java From FamilyChat with Apache License 2.0 | 4 votes |
/** * 恢复语音传输 * 【取消静音】 */ public void resumeVoiceTransfer() throws HyphenateException { EMClient.getInstance().callManager().resumeVoiceTransfer(); }
Example #20
Source File: ChooseFriendActivity.java From Social with Apache License 2.0 | 4 votes |
private void handleInviteFriendToGroup(Message msg){ String result = msg.obj.toString(); Log.d("ChooseFriendActivity", result); Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create(); Root root = gson.fromJson(result, Root.class); if(root==null){ Toast.makeText(this,"服务器繁忙,请重试",Toast.LENGTH_LONG).show(); return ; } if (root.success == false){ new Dialog(this,"提示",root.message).show(); return; } //成功之后邀请 new Thread(new Runnable() { @Override public void run() { try { if (owner_username.equals(SharedPreferenceUtil.getUserName())){ //群主邀请 EMClient.getInstance().groupManager().addUsersToGroup(hx_group_id, new String[]{applyer_username});//需异步处理 Log.d("GroupMember","群主邀请"); }else{ //群成员邀请 Log.d("GroupMember", "成员邀请之前"); EMClient.getInstance().groupManager().inviteUser(hx_group_id, new String[]{applyer_username},"");//需异步处理 Log.d("GroupMember", "成员邀请之后"); } }catch (HyphenateException e){ Log.d("GroupMember", "邀请失败"); e.printStackTrace(); } } }).start(); Toast.makeText(this,"邀请成功",Toast.LENGTH_LONG).show(); this.finish(); }
Example #21
Source File: AddGroupActivity.java From Social with Apache License 2.0 | 4 votes |
@Override public void onClick(View view) { int id = view.getId(); switch (id){ case R.id.id_add_group_iv_group_img: CommentUtil.startPicChoiceIntent(this); break; case R.id.id_add_group_btn_add: groupname = et_groupname.getText().toString(); if (groupname.equals("")) {new Dialog(this,"Tips","请输入群名称").show(); return;} description = et_group_description.getText().toString(); if (description.equals("")) {new Dialog(this,"Tips","请输入群介绍").show(); return; } point = tv_choose_point.getText().toString(); if (point.equals("请选择")) {new Dialog(this,"Tips","请选择群组地点").show(); return;} if (rb_private_1.isChecked()){ group_type = 1; }else if (rb_private_2.isChecked()){ group_type = 2; }else if (rb_public_1.isChecked()){ group_type = 3; }else if (rb_public_2.isChecked()){ group_type = 4; } showProgressDialog(); try { EMGroupManager.EMGroupOptions option = new EMGroupManager.EMGroupOptions(); option.maxUsers = 200; switch (group_type){ case 1: option.style = EMGroupManager.EMGroupStyle.EMGroupStylePrivateMemberCanInvite;//私有群,群成员也能邀请人进群; break; case 2: option.style = EMGroupManager.EMGroupStyle.EMGroupStylePrivateOnlyOwnerInvite;//私有群,只能群主邀请人进群; break; case 3: option.style = EMGroupManager.EMGroupStyle.EMGroupStylePublicJoinNeedApproval;//公开群,加入此群除了群主邀请,只能通过申请加入此群;; break; case 4: option.style = EMGroupManager.EMGroupStyle.EMGroupStylePublicOpenJoin ;//公开群,任何人都能加入此群。; break; } //option.style = EMGroupManager.EMGroupStyle.EMGroupStylePrivateMemberCanInvite;//私有群,群成员也能邀请人进群; //option.style = EMGroupManager.EMGroupStyle.EMGroupStylePrivateOnlyOwnerInvite;//私有群,只能群主邀请人进群; //option.style = EMGroupManager.EMGroupStyle.EMGroupStylePublicJoinNeedApproval;//公开群,加入此群除了群主邀请,只能通过申请加入此群;; //option.style = EMGroupManager.EMGroupStyle.EMGroupStylePublicOpenJoin ;//公开群,任何人都能加入此群。; EMGroup group = EMClient.getInstance().groupManager().createGroup(groupname, description, new String[]{SharedPreferenceUtil.getUserName()}, "reason", option); Log.d("AddGroupActivity", "group_id = " + group.getGroupId() + "\n" + "group_name = " + group.getGroupName() + "\n" + "group_desc = " + group.getDescription() + "\n" + "group_owner = " + group.getOwner()); hx_group_id = group.getGroupId(); }catch (HyphenateException e){ e.printStackTrace(); } addGroup(); break; case R.id.id_add_group_tv_choose_point: Intent intent = new Intent(this,ChoosePointActivity.class); startActivityForResult(intent,REQUESTCODE_CHOOSE_POINT); break; } }
Example #22
Source File: HxCallHelper.java From FamilyChat with Apache License 2.0 | 2 votes |
/** * 暂停视频传输 * * @throws HyphenateException */ public void pauseVideoTransfer() throws HyphenateException { EMClient.getInstance().callManager().pauseVideoTransfer(); }
Example #23
Source File: HxCallHelper.java From FamilyChat with Apache License 2.0 | 2 votes |
/** * 恢复视频传输 * * @throws HyphenateException */ public void resumeSurfaceView() throws HyphenateException { EMClient.getInstance().callManager().resumeVideoTransfer(); }
Example #24
Source File: HxSdkHelper.java From FamilyChat with Apache License 2.0 | 2 votes |
/** * 添加好友 * * @param phone 手机号 * @throws HyphenateException 鬼知道什么异常 */ public void addFriend(String phone) throws HyphenateException { EMClient.getInstance().contactManager().addContact(phone, null); }
Example #25
Source File: HxSdkHelper.java From FamilyChat with Apache License 2.0 | 2 votes |
/** * 删除好友 * * @param phone 手机号 * @throws HyphenateException 鬼知道什么异常 */ public void deleteFriend(String phone) throws HyphenateException { EMClient.getInstance().contactManager().deleteContact(phone); }