@Override public void onClick(View v) { switch (v.getId()) { case R.id.add_black: if (RongIM.getInstance() != null && Util.getNetWorkType(this) != -1) { RongIM.getInstance() .addToBlacklist( userId, new RongIM.OperationCallback() { @Override public void onError(ErrorCode errorCode) { Log.e( TAG, "-------addToBlacklist onError----------:" + errorCode.getMessage()); Log.e(TAG, "-------addToBlacklist onError---------:" + errorCode.getValue()); } @Override public void onSuccess() { Log.e(TAG, "-------添加到黑名单--------:"); Message msg = Message.obtain(); msg.what = 1; mHandler.sendMessage(msg); } }); } else { WinToast.toast(this, R.string.network_not); } break; case R.id.remove_black: if (RongIM.getInstance() != null && Util.getNetWorkType(this) != -1) { RongIM.getInstance() .removeFromBlacklist( userId, new RongIM.OperationCallback() { @Override public void onError(ErrorCode errorCode) { Log.e(TAG, "------- removeFromBlacklist onError-------:" + errorCode); } @Override public void onSuccess() { Log.e(TAG, "-------被移除黑名单-------:"); Message msg = Message.obtain(); msg.what = 2; mHandler.sendMessage(msg); } }); } else { WinToast.toast(this, R.string.network_not); } break; default: break; } }
@Override protected void initData() { mAddBlack.setOnClickListener(this); mRemoveBlack.setOnClickListener(this); if (RongIM.getInstance() != null && Util.getNetWorkType(this) != -1) { if (userId.equals(LoginActivity.mUserID)) { mUserInfo.setVisibility(View.GONE); } else { RongIM.getInstance() .getBlacklistStatus( userId, new RongIM.GetUserBlacklistCallback() { @Override public void onError(ErrorCode errorCode) { Log.e( TAG, "-------getBlacklistStatus onError---------:" + errorCode.getMessage() + ",:" + errorCode.getValue()); mUserInfo.setText(errorCode + ""); } @Override public void onSuccess(RongIMClient.BlacklistStatus status) { Log.e(TAG, "-------getBlacklistStatus onSuccess---------:" + status); if (status == RongIMClient.BlacklistStatus.NOT_EXIT_BLACK_LIST) { mUserInfo.setText(title); mAddBlack.setVisibility(View.VISIBLE); } else if (status == RongIMClient.BlacklistStatus.EXIT_BLACK_LIST) { mUserInfo.setText(title + "已被加入黑名单,无法收到此用户消息"); mRemoveBlack.setVisibility(View.VISIBLE); } } }); } } else { WinToast.toast(UserInfoActivity.this, R.string.network_not); } }