private EaseUser getUserInfo(final String username){
// To get instance of EaseUser, here we get it from the user list in memory
// You'd better cache it if you get it from your server
String curUser = EMClient.getInstance().getCurrentUser();
if(username==null||curUser==null)return null;
EaseUser user = null;
/* if(username.equals(curUser))
return getUserProfileManager().getCurrentUserInfo();*/
user = getContactList().get(username);
if(user == null && getRobotList() != null){
user = getRobotList().get(username);
}
// if user is not in your contacts, set inital letter for him/her
if(user == null){
user = new EaseUser(username);
EaseCommonUtils.setUserInitialLetter(user);
final UserBean.Account[] account = {null};
MyApplication.getInstance().getCurrentActivity().runOnUiThread(new Runnable() {
public void run() {
account[0] = AccountLoader.getUser(username);
}
});
if(account[0] !=null) {
user = new EaseUser(account[0].getId());
user.setNickname(account[0].getNickname());
user.setAvatar(account[0].getAvatar());
userDao.saveContact(user);
}
}
return user;
}