你的位置:首页 > 操作系统

[操作系统]硅谷社交6


1.查找按钮的处理

// 去服务器判断当前查找的用户是否存在userInfo = new UserInfo(name);// 更新UI显示runOnUiThread(new Runnable() {	@Override	public void run() {		rl_add.setVisibility(View.VISIBLE);		tv_add_name.setText(userInfo.getName());	}});

  

2.添加按钮处理

Model.getInstance().getGlobalThreadPool().execute(new Runnable() {	@Override	public void run() {		// 去环信服务器添加好友		try {			EMClient.getInstance().contactManager().addContact(userInfo.getName(), "添加好友");			runOnUiThread(new Runnable() {				@Override				public void run() {					Toast.makeText(AddContactActivity.this, "发送添加好友邀请成功", Toast.LENGTH_SHORT).show();				}			});		} catch (final HyphenateException e) {			e.printStackTrace();			runOnUiThread(new Runnable() {				@Override				public void run() {					Toast.makeText(AddContactActivity.this, "发送添加好友邀请失败" + e.toString(), Toast.LENGTH_SHORT).show();				}			});		}	}});