本文整理汇总了Java中com.easemob.EMError类的典型用法代码示例。如果您正苦于以下问题:Java EMError类的具体用法?Java EMError怎么用?Java EMError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EMError类属于com.easemob包,在下文中一共展示了EMError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stopRecoding
import com.easemob.EMError; //导入依赖的package包/类
public int stopRecoding() {
if(recorder != null){
isRecording = false;
recorder.stop();
recorder.release();
recorder = null;
if(file == null || !file.exists() || !file.isFile()){
return EMError.INVALID_FILE;
}
if (file.length() == 0) {
file.delete();
return EMError.INVALID_FILE;
}
int seconds = (int) (new Date().getTime() - startTime) / 1000;
EMLog.d("voice", "voice recording finished. seconds:" + seconds + " file length:" + file.length());
return seconds;
}
return 0;
}
示例2: updateView
import com.easemob.EMError; //导入依赖的package包/类
protected void updateView() {
activity.runOnUiThread(new Runnable() {
public void run() {
if (message.status == EMMessage.Status.FAIL) {
if (message.getError() == EMError.MESSAGE_SEND_INVALID_CONTENT) {
Toast.makeText(activity,activity.getString(R.string.send_fail) + activity.getString(R.string.error_send_invalid_content), 0).show();
} else if (message.getError() == EMError.MESSAGE_SEND_NOT_IN_THE_GROUP) {
Toast.makeText(activity,activity.getString(R.string.send_fail) + activity.getString(R.string.error_send_not_in_the_group), 0).show();
} else {
Toast.makeText(activity,activity.getString(R.string.send_fail) + activity.getString(R.string.connect_failuer_toast), 0).show();
}
}
onUpdateView();
}
});
}
示例3: updateView
import com.easemob.EMError; //导入依赖的package包/类
protected void updateView() {
activity.runOnUiThread(new Runnable() {
public void run() {
if (message.status == EMMessage.Status.FAIL) {
if (message.getError() == EMError.MESSAGE_SEND_INVALID_CONTENT) {
Toast.makeText(activity,activity.getString(R.string.send_fail) + activity.getString(R.string.error_send_invalid_content), 0).show();
} else if (message.getError() == EMError.MESSAGE_SEND_NOT_IN_THE_GROUP) {
Toast.makeText(activity,activity.getString(R.string.send_fail) + activity.getString(R.string.error_send_not_in_the_group), 0).show();
} else if (message.getError() == EMError.MESSAGE_SEND_IN_BLACKLIST) {
Toast.makeText(activity,activity.getString(R.string.send_fail) + activity.getString(R.string.error_send_in_blacklist), 0).show();
} else {
Toast.makeText(activity,activity.getString(R.string.send_fail) + activity.getString(R.string.connect_failuer_toast), 0).show();
}
}
onUpdateView();
}
});
}
示例4: initListener
import com.easemob.EMError; //导入依赖的package包/类
/**
* init HuanXin listeners
*/
protected void initListener(){
Log.d(TAG, "init listener");
// create the global connection listener
connectionListener = new EMConnectionListener() {
@Override
public void onDisconnected(int error) {
if (error == EMError.USER_REMOVED) {
onCurrentAccountRemoved();
}else if (error == EMError.CONNECTION_CONFLICT) {
onConnectionConflict();
}else{
onConnectionDisconnected(error);
}
}
@Override
public void onConnected() {
onConnectionConnected();
}
};
//注册连接监听
EMChatManager.getInstance().addConnectionListener(connectionListener);
}
示例5: onDisconnected
import com.easemob.EMError; //导入依赖的package包/类
@Override
public void onDisconnected(final int error) {
final String st1 = getResources().getString(R.string.can_not_connect_chat_server_connection);
final String st2 = getResources().getString(R.string.the_current_network);
runOnUiThread(new Runnable() {
@Override
public void run() {
if (error == EMError.USER_REMOVED) {
// 显示帐号已经被移除
showAccountRemovedDialog();
} else if (error == EMError.CONNECTION_CONFLICT) {
// 显示帐号在其他设备登陆dialog
showConflictDialog();
} else {
chatHistoryFragment.errorItem.setVisibility(View.VISIBLE);
if (NetUtils.hasNetwork(EMChatMainActivity.this))
chatHistoryFragment.errorText.setText(st1);
else
chatHistoryFragment.errorText.setText(st2);
}
}
});
}
示例6: stopRecoding
import com.easemob.EMError; //导入依赖的package包/类
public int stopRecoding() {
if (recorder != null) {
isRecording = false;
recorder.stop();
recorder.release();
recorder = null;
if (file == null || !file.exists() || !file.isFile()) {
return EMError.INVALID_FILE;
}
if (file.length() == 0) {
file.delete();
return EMError.INVALID_FILE;
}
int seconds = (int) (new Date().getTime() - startTime) / 1000;
EMLog.d("voice", "voice recording finished. seconds:" + seconds + " file length:" + file.length());
return seconds;
}
return 0;
}
示例7: updateView
import com.easemob.EMError; //导入依赖的package包/类
protected void updateView() {
activity.runOnUiThread(new Runnable() {
public void run() {
if (message.status == EMMessage.Status.FAIL) {
if (message.getError() == EMError.MESSAGE_SEND_INVALID_CONTENT) {
Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.error_send_invalid_content), 0).show();
} else if (message.getError() == EMError.MESSAGE_SEND_NOT_IN_THE_GROUP) {
Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.error_send_not_in_the_group), 0).show();
} else {
Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.connect_failuer_toast), 0).show();
}
}
onUpdateView();
}
});
}
示例8: onDisconnected
import com.easemob.EMError; //导入依赖的package包/类
@Override
public void onDisconnected(int error) {
if (error == EMError.USER_REMOVED || error == EMError.CONNECTION_CONFLICT) {
isConflict = true;
} else {
handler.sendEmptyMessage(0);
}
}
示例9: onDisconnected
import com.easemob.EMError; //导入依赖的package包/类
@Override
public void onDisconnected(int error) {
if (error == EMError.USER_REMOVED || error == EMError.CONNECTION_CONFLICT) {
isConflict = true;
} else {
getActivity().runOnUiThread(new Runnable() {
public void run() {
onConnectionDisconnected();
}
});
}
}
示例10: onDisconnected
import com.easemob.EMError; //导入依赖的package包/类
@Override
public void onDisconnected(int error) {
if (error == EMError.USER_REMOVED || error == EMError.CONNECTION_CONFLICT) {
isConflict = true;
} else {
handler.sendEmptyMessage(0);
}
}
示例11: onDisconnected
import com.easemob.EMError; //导入依赖的package包/类
@Override
public void onDisconnected(int error) {
if (error == EMError.USER_REMOVED || error == EMError.CONNECTION_CONFLICT) {
isConflict = true;
} else {
handler.sendEmptyMessage(0);
}
}
示例12: updateSendedView
import com.easemob.EMError; //导入依赖的package包/类
/**
* 更新ui上消息发送状态
*
* @param message
* @param holder
*/
private void updateSendedView(final EMMessage message, final ViewHolder holder) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
// send success
if (message.getType() == EMMessage.Type.VIDEO) {
holder.tv.setVisibility(View.GONE);
}
EMLog.d(TAG, "message status : " + message.status);
if (message.status == EMMessage.Status.SUCCESS) {
// if (message.getType() == EMMessage.Type.FILE) {
// holder.pb.setVisibility(View.INVISIBLE);
// holder.staus_iv.setVisibility(View.INVISIBLE);
// } else {
// holder.pb.setVisibility(View.GONE);
// holder.staus_iv.setVisibility(View.GONE);
// }
} else if (message.status == EMMessage.Status.FAIL) {
// if (message.getType() == EMMessage.Type.FILE) {
// holder.pb.setVisibility(View.INVISIBLE);
// } else {
// holder.pb.setVisibility(View.GONE);
// }
// holder.staus_iv.setVisibility(View.VISIBLE);
if(message.getError() == EMError.MESSAGE_SEND_INVALID_CONTENT){
Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.error_send_invalid_content), Toast.LENGTH_SHORT)
.show();
}else if(message.getError() == EMError.MESSAGE_SEND_NOT_IN_THE_GROUP){
Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.error_send_not_in_the_group), Toast.LENGTH_SHORT)
.show();
}else{
Toast.makeText(activity, activity.getString(R.string.send_fail) + activity.getString(R.string.connect_failuer_toast), Toast.LENGTH_SHORT)
.show();
}
}
notifyDataSetChanged();
}
});
}
示例13: setGlobalListeners
import com.easemob.EMError; //导入依赖的package包/类
/**
* 设置全局事件监听
*/
protected void setGlobalListeners(){
syncGroupsListeners = new ArrayList<DataSyncListener>();
syncContactsListeners = new ArrayList<DataSyncListener>();
syncBlackListListeners = new ArrayList<DataSyncListener>();
isGroupsSyncedWithServer = demoModel.isGroupsSynced();
isContactsSyncedWithServer = demoModel.isContactSynced();
isBlackListSyncedWithServer = demoModel.isBacklistSynced();
// create the global connection listener
connectionListener = new EMConnectionListener() {
@Override
public void onDisconnected(int error) {
if (error == EMError.USER_REMOVED) {
onCurrentAccountRemoved();
}else if (error == EMError.CONNECTION_CONFLICT) {
onConnectionConflict();
}
}
@Override
public void onConnected() {
// in case group and contact were already synced, we supposed to notify sdk we are ready to receive the events
if(isGroupsSyncedWithServer && isContactsSyncedWithServer){
new Thread(){
@Override
public void run(){
DemoHelper.getInstance().notifyForRecevingEvents();
}
}.start();
}else{
if(!isGroupsSyncedWithServer){
asyncFetchGroupsFromServer(null);
}
if(!isContactsSyncedWithServer){
asyncFetchContactsFromServer(null);
}
if(!isBlackListSyncedWithServer){
asyncFetchBlackListFromServer(null);
}
}
// 当连接到服务器之后,这里开始检查是否有没有发送的ack回执消息,
EaseACKUtil.getInstance(appContext).checkACKData();
}
};
IntentFilter callFilter = new IntentFilter(EMChatManager.getInstance().getIncomingCallBroadcastAction());
if(callReceiver == null){
callReceiver = new CallReceiver();
}
//注册通话广播接收者
appContext.registerReceiver(callReceiver, callFilter);
//注册连接监听
EMChatManager.getInstance().addConnectionListener(connectionListener);
//注册群组和联系人监听
registerGroupAndContactListener();
//注册消息事件监听
registerEventListener();
}
示例14: searchGroup
import com.easemob.EMError; //导入依赖的package包/类
/**
* 搜索
* @param v
*/
public void searchGroup(View v){
if(TextUtils.isEmpty(idET.getText())){
return;
}
final ProgressDialog pd = new ProgressDialog(this);
pd.setMessage(getResources().getString(R.string.searching));
pd.setCancelable(false);
pd.show();
new Thread(new Runnable() {
public void run() {
try {
searchedGroup = EMGroupManager.getInstance().getGroupFromServer(idET.getText().toString());
runOnUiThread(new Runnable() {
public void run() {
pd.dismiss();
containerLayout.setVisibility(View.VISIBLE);
nameText.setText(searchedGroup.getGroupName());
}
});
} catch (final EaseMobException e) {
e.printStackTrace();
runOnUiThread(new Runnable() {
public void run() {
pd.dismiss();
searchedGroup = null;
containerLayout.setVisibility(View.GONE);
if(e.getErrorCode() == EMError.GROUP_NOT_EXIST){
Toast.makeText(getApplicationContext(), getResources().getString(R.string.group_not_existed), 0).show();
}else{
Toast.makeText(getApplicationContext(), getResources().getString(R.string.group_search_failed) + " : " + getString(R.string.connect_failuer_toast), 0).show();
}
}
});
}
}
}).start();
}
示例15: register
import com.easemob.EMError; //导入依赖的package包/类
/**
* 注册
*
* @param view
*/
public void register(View view) {
final String username = userNameEditText.getText().toString().trim();
final String pwd = passwordEditText.getText().toString().trim();
String confirm_pwd = confirmPwdEditText.getText().toString().trim();
if (TextUtils.isEmpty(username)) {
Toast.makeText(this, getResources().getString(R.string.User_name_cannot_be_empty), Toast.LENGTH_SHORT).show();
userNameEditText.requestFocus();
return;
} else if (TextUtils.isEmpty(pwd)) {
Toast.makeText(this, getResources().getString(R.string.Password_cannot_be_empty), Toast.LENGTH_SHORT).show();
passwordEditText.requestFocus();
return;
} else if (TextUtils.isEmpty(confirm_pwd)) {
Toast.makeText(this, getResources().getString(R.string.Confirm_password_cannot_be_empty), Toast.LENGTH_SHORT).show();
confirmPwdEditText.requestFocus();
return;
} else if (!pwd.equals(confirm_pwd)) {
Toast.makeText(this, getResources().getString(R.string.Two_input_password), Toast.LENGTH_SHORT).show();
return;
}
if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) {
final ProgressDialog pd = new ProgressDialog(this);
pd.setMessage(getResources().getString(R.string.Is_the_registered));
pd.show();
new Thread(new Runnable() {
public void run() {
try {
// 调用sdk注册方法
EMChatManager.getInstance().createAccountOnServer(username, pwd);
runOnUiThread(new Runnable() {
public void run() {
if (!RegisterActivity.this.isFinishing())
pd.dismiss();
// 保存用户名
DemoHelper.getInstance().setCurrentUserName(username);
Toast.makeText(getApplicationContext(), getResources().getString(R.string.Registered_successfully), 0).show();
finish();
}
});
} catch (final EaseMobException e) {
runOnUiThread(new Runnable() {
public void run() {
if (!RegisterActivity.this.isFinishing())
pd.dismiss();
int errorCode=e.getErrorCode();
if(errorCode==EMError.NONETWORK_ERROR){
Toast.makeText(getApplicationContext(), getResources().getString(R.string.network_anomalies), Toast.LENGTH_SHORT).show();
}else if(errorCode == EMError.USER_ALREADY_EXISTS){
Toast.makeText(getApplicationContext(), getResources().getString(R.string.User_already_exists), Toast.LENGTH_SHORT).show();
}else if(errorCode == EMError.UNAUTHORIZED){
Toast.makeText(getApplicationContext(), getResources().getString(R.string.registration_failed_without_permission), Toast.LENGTH_SHORT).show();
}else if(errorCode == EMError.ILLEGAL_USER_NAME){
Toast.makeText(getApplicationContext(), getResources().getString(R.string.illegal_user_name),Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(getApplicationContext(), getResources().getString(R.string.Registration_failed) + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
}
}).start();
}
}