Search in sources :

Example 11 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class AddGroupChatActivity method initData.

@Override
protected void initData() {
    // 获取好友列表
    alluserList = new ArrayList<User>();
    for (User user : GloableParams.UserInfos) {
        if (!user.getUserName().equals(Constant.NEW_FRIENDS_USERNAME) & !user.getUserName().equals(Constant.GROUP_USERNAME))
            alluserList.add(user);
    }
    contactAdapter = new ContactAdapter(AddGroupChatActivity.this, alluserList);
    listView.setAdapter(contactAdapter);
}
Also used : User(com.juns.wechat.bean.User)

Example 12 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class AddGroupChatActivity method setListener.

@Override
protected void setListener() {
    img_back.setOnClickListener(this);
    tv_header.setOnClickListener(this);
    txt_right.setOnClickListener(this);
    et_search.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() > 0) {
                String str_s = et_search.getText().toString().trim();
                List<User> users_temp = new ArrayList<User>();
                for (User user : alluserList) {
                    String usernick = user.getUserName();
                    if (usernick.contains(str_s)) {
                        users_temp.add(user);
                    }
                    contactAdapter = new ContactAdapter(AddGroupChatActivity.this, users_temp);
                    listView.setAdapter(contactAdapter);
                }
            } else {
                contactAdapter = new ContactAdapter(AddGroupChatActivity.this, alluserList);
                listView.setAdapter(contactAdapter);
            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable s) {
        }
    });
}
Also used : User(com.juns.wechat.bean.User) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) List(java.util.List) ArrayList(java.util.ArrayList)

Example 13 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class AddGroupChatActivity method save.

/**
	 * 确认选择的members
	 * 
	 * @param v
	 */
public void save() {
    if (addList.size() == 0) {
        Utils.showLongToast(AddGroupChatActivity.this, "请选择用户");
        return;
    }
    // 如果只有一个用户说明只是单聊,并且不是从群组加人
    if (addList.size() == 1 && isCreatingNewGroup) {
        String userId = addList.get(0);
        User user = GloableParams.Users.get(userId);
        Intent intent = new Intent(AddGroupChatActivity.this, ChatActivity.class);
        intent.putExtra(Constants.NAME, user.getUserName());
        intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
        intent.putExtra(Constants.User_ID, user.getTelephone());
        startActivity(intent);
        overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
    } else {
        if (isCreatingNewGroup) {
            getLoadingDialog("正在创建群聊...").show();
        } else {
            getLoadingDialog("正在加人...").show();
        }
        // 创建群组
        creatNewGroup(addList);
    }
}
Also used : User(com.juns.wechat.bean.User) Intent(android.content.Intent)

Example 14 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class AddGroupChatActivity method creatNewGroup.

private void creatNewGroup(final List<String> members) {
    // TODO 请求服务器创建群组,服务端实现接口
    new Thread(new Runnable() {

        @Override
        public void run() {
            // 调用sdk创建群组方法
            try {
                final String[] strmembers = new String[members.size()];
                for (int i = 0; i < members.size(); i++) {
                    User user = GloableParams.Users.get(members.get(i));
                    if (user != null) {
                        if (i < 3) {
                            if (i == 0)
                                groupName = user.getUserName();
                            else
                                groupName += "、" + user.getUserName();
                        } else if (i == 4) {
                            groupName += "...";
                        }
                        strmembers[i] = user.getTelephone();
                        if (i == 0) {
                            manber = user.getTelephone();
                        } else {
                            manber += "、" + user.getTelephone();
                        }
                    }
                }
                final EMGroup group = EMGroupManager.getInstance().createPublicGroup(groupName, "", strmembers, true);
                runOnUiThread(new Runnable() {

                    public void run() {
                        if (group != null) {
                            // TODO 保存本地数据库
                            GloableParams.GroupInfos = new HashMap<String, GroupInfo>();
                            GroupInfo info = new GroupInfo();
                            info.setGroup_id(group.getGroupId());
                            info.setGroup_name(groupName);
                            info.setMembers(manber);
                            String owner_id = Utils.getValue(AddGroupChatActivity.this, Constants.User_ID);
                            info.setOwner_id(owner_id);
                            GloableParams.GroupInfos.put(group.getGroupId(), info);
                            FinalDb db = FinalDb.create(AddGroupChatActivity.this, Constants.DB_NAME, false);
                            db.save(info);
                            addServieGroup(group.getGroupId(), groupName, manber, // 保存服务器
                            owner_id);
                        }
                    }
                });
            } catch (final EaseMobException e) {
                runOnUiThread(new Runnable() {

                    public void run() {
                        Utils.showLongToast(AddGroupChatActivity.this, "创建失败");
                        getLoadingDialog("正在创建群聊...").dismiss();
                    }
                });
            }
        }
    }).start();
}
Also used : User(com.juns.wechat.bean.User) EaseMobException(com.easemob.exceptions.EaseMobException) HashMap(java.util.HashMap) GroupInfo(com.juns.wechat.bean.GroupInfo) EMGroup(com.easemob.chat.EMGroup) FinalDb(net.tsz.afinal.FinalDb)

Example 15 with User

use of com.juns.wechat.bean.User in project wechat by motianhuo.

the class FriendMsgActivity method initData.

@Override
protected void initData() {
    UserId = getIntent().getStringExtra(Constants.User_ID);
    Name = getIntent().getStringExtra(Constants.NAME);
    if (TextUtils.isEmpty(UserId))
        finish();
    else {
        User user = GloableParams.Users.get(UserId);
        tv_name.setText(user.getUserName());
        tv_accout.setText("微信号:" + UserId);
    }
}
Also used : User(com.juns.wechat.bean.User)

Aggregations

User (com.juns.wechat.bean.User)23 Intent (android.content.Intent)5 ImageView (android.widget.ImageView)5 GroupInfo (com.juns.wechat.bean.GroupInfo)5 TextView (android.widget.TextView)4 FinalDb (net.tsz.afinal.FinalDb)4 View (android.view.View)3 OnClickListener (android.view.View.OnClickListener)3 EaseMobException (com.easemob.exceptions.EaseMobException)3 BaseJsonRes (com.juns.wechat.net.BaseJsonRes)3 List (java.util.List)3 EMConversation (com.easemob.chat.EMConversation)2 RequestParams (com.juns.health.net.loopj.android.http.RequestParams)2 FriendMsgActivity (com.juns.wechat.view.activity.FriendMsgActivity)2 Bitmap (android.graphics.Bitmap)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 EMGroup (com.easemob.chat.EMGroup)1 EMMessage (com.easemob.chat.EMMessage)1 ImageMessageBody (com.easemob.chat.ImageMessageBody)1