use of com.hyphenate.easeui.domain.EaseUser in project SmartCampus by Vegen.
the class EaseChatFragment method inputAtUsername.
/**
* input @
* @param username
*/
protected void inputAtUsername(String username, boolean autoAddAtSymbol) {
if (EMClient.getInstance().getCurrentUser().equals(username) || chatType != EaseConstant.CHATTYPE_GROUP) {
return;
}
EaseAtMessageHelper.get().addAtUser(username);
EaseUser user = EaseUserUtils.getUserInfo(username);
if (user != null) {
username = user.getNick();
}
if (autoAddAtSymbol)
inputMenu.insertText("@" + username + " ");
else
inputMenu.insertText(username + " ");
}
use of com.hyphenate.easeui.domain.EaseUser in project SmartCampus by Vegen.
the class EaseChatFragment method setUpView.
protected void setUpView() {
titleBar.setTitle(toChatUsername);
if (chatType == EaseConstant.CHATTYPE_SINGLE) {
// set title
if (EaseUserUtils.getUserInfo(toChatUsername) != null) {
EaseUser user = EaseUserUtils.getUserInfo(toChatUsername);
if (user != null) {
titleBar.setTitle(user.getNick());
}
}
titleBar.setRightImageResource(R.drawable.ease_mm_title_remove);
} else {
titleBar.setRightImageResource(R.drawable.ease_to_group_details_normal);
if (chatType == EaseConstant.CHATTYPE_GROUP) {
// group chat
EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername);
if (group != null)
titleBar.setTitle(group.getGroupName());
// listen the event that user moved out group or group is dismissed
groupListener = new GroupListener();
EMClient.getInstance().groupManager().addGroupChangeListener(groupListener);
} else {
chatRoomListener = new ChatRoomListener();
EMClient.getInstance().chatroomManager().addChatRoomChangeListener(chatRoomListener);
onChatRoomViewCreation();
}
}
if (chatType != EaseConstant.CHATTYPE_CHATROOM) {
onConversationInit();
onMessageListInit();
}
titleBar.setLeftLayoutClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
titleBar.setRightLayoutClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (chatType == EaseConstant.CHATTYPE_SINGLE) {
emptyHistory();
} else {
toGroupDetails();
}
}
});
setRefreshLayoutListener();
// show forward message if the message is not null
String forward_msg_id = getArguments().getString("forward_msg_id");
if (forward_msg_id != null) {
forwardMessage(forward_msg_id);
}
}
use of com.hyphenate.easeui.domain.EaseUser in project SmartCampus by Vegen.
the class EaseContactListFragment method setUpView.
@Override
protected void setUpView() {
EMClient.getInstance().addConnectionListener(connectionListener);
contactList = new ArrayList<EaseUser>();
getContactList();
// init list
contactListLayout.init(contactList);
if (listItemClickListener != null) {
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
EaseUser user = (EaseUser) listView.getItemAtPosition(position);
listItemClickListener.onListItemClicked(user);
}
});
}
query.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
contactListLayout.filter(s);
if (s.length() > 0) {
clearSearch.setVisibility(View.VISIBLE);
} else {
clearSearch.setVisibility(View.INVISIBLE);
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void afterTextChanged(Editable s) {
}
});
clearSearch.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
query.getText().clear();
hideSoftKeyboard();
}
});
listView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
hideSoftKeyboard();
return false;
}
});
}
use of com.hyphenate.easeui.domain.EaseUser in project SmartCampus by Vegen.
the class EaseContactListFragment method getContactList.
/**
* get contact list and sort, will filter out users in blacklist
*/
protected void getContactList() {
contactList.clear();
if (contactsMap == null) {
return;
}
synchronized (this.contactsMap) {
Iterator<Entry<String, EaseUser>> iterator = contactsMap.entrySet().iterator();
List<String> blackList = EMClient.getInstance().contactManager().getBlackListUsernames();
while (iterator.hasNext()) {
Entry<String, EaseUser> entry = iterator.next();
// to make it compatible with data in previous version, you can remove this check if this is new app
if (!entry.getKey().equals("item_new_friends") && !entry.getKey().equals("item_groups") && !entry.getKey().equals("item_chatroom") && !entry.getKey().equals("item_robots")) {
if (!blackList.contains(entry.getKey())) {
// filter out users in blacklist
EaseUser user = entry.getValue();
EaseCommonUtils.setUserInitialLetter(user);
contactList.add(user);
}
}
}
}
// sorting
Collections.sort(contactList, new Comparator<EaseUser>() {
@Override
public int compare(EaseUser lhs, EaseUser rhs) {
if (lhs.getInitialLetter().equals(rhs.getInitialLetter())) {
return lhs.getNick().compareTo(rhs.getNick());
} else {
if ("#".equals(lhs.getInitialLetter())) {
return 1;
} else if ("#".equals(rhs.getInitialLetter())) {
return -1;
}
return lhs.getInitialLetter().compareTo(rhs.getInitialLetter());
}
}
});
}
use of com.hyphenate.easeui.domain.EaseUser in project SmartCampus by Vegen.
the class EaseUserUtils method setUserAvatar.
/**
* set user avatar
* @param username
*/
public static void setUserAvatar(Context context, String username, ImageView imageView) {
EaseUser user = getUserInfo(username);
if (user != null && user.getAvatar() != null) {
try {
int avatarResId = Integer.parseInt(user.getAvatar());
Glide.with(context).load(avatarResId).into(imageView);
} catch (Exception e) {
// use default avatar
Glide.with(context).load(user.getAvatar()).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.ease_default_avatar).into(imageView);
}
} else {
Glide.with(context).load(R.drawable.ease_default_avatar).into(imageView);
}
}
Aggregations