Search in sources :

Example 1 with EaseUser

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 + " ");
}
Also used : EaseUser(com.hyphenate.easeui.domain.EaseUser)

Example 2 with EaseUser

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);
    }
}
Also used : EMGroup(com.hyphenate.chat.EMGroup) OnClickListener(android.view.View.OnClickListener) EaseUser(com.hyphenate.easeui.domain.EaseUser) View(android.view.View) ListView(android.widget.ListView) EaseVoiceRecorderView(com.hyphenate.easeui.widget.EaseVoiceRecorderView)

Example 3 with EaseUser

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;
        }
    });
}
Also used : OnTouchListener(android.view.View.OnTouchListener) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) MotionEvent(android.view.MotionEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) OnClickListener(android.view.View.OnClickListener) EaseUser(com.hyphenate.easeui.domain.EaseUser)

Example 4 with EaseUser

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());
            }
        }
    });
}
Also used : Entry(java.util.Map.Entry) EaseUser(com.hyphenate.easeui.domain.EaseUser)

Example 5 with EaseUser

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);
    }
}
Also used : EaseUser(com.hyphenate.easeui.domain.EaseUser)

Aggregations

EaseUser (com.hyphenate.easeui.domain.EaseUser)6 View (android.view.View)2 OnClickListener (android.view.View.OnClickListener)2 ListView (android.widget.ListView)2 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 MotionEvent (android.view.MotionEvent)1 OnTouchListener (android.view.View.OnTouchListener)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 EMGroup (com.hyphenate.chat.EMGroup)1 EaseAvatarOptions (com.hyphenate.easeui.domain.EaseAvatarOptions)1 EaseImageView (com.hyphenate.easeui.widget.EaseImageView)1 EaseVoiceRecorderView (com.hyphenate.easeui.widget.EaseVoiceRecorderView)1 Entry (java.util.Map.Entry)1