Search in sources :

Example 1 with GroupInfo

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

the class MyGroupAdpter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.layout_item_mygroup, parent, false);
    }
    final GroupInfo group = grouplist.get(position);
    ImageView img_avar = ViewHolder.get(convertView, R.id.img_photo);
    TextView txt_name = ViewHolder.get(convertView, R.id.txt_name);
    img_avar.setImageResource(R.drawable.defult_group);
    txt_name.setText(group.getGroup_name());
    convertView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, ChatActivity.class);
            intent.putExtra(Constants.NAME, group.getGroup_name());
            intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP);
            intent.putExtra(Constants.GROUP_ID, group.getGroup_id());
            context.startActivity(intent);
        }
    });
    return convertView;
}
Also used : ChatActivity(com.juns.wechat.chat.ChatActivity) GroupInfo(com.juns.wechat.bean.GroupInfo) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) Intent(android.content.Intent) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with GroupInfo

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

the class SplashActivity method initData.

private void initData() {
    GloableParams.UserInfos = new ArrayList<User>();
    GloableParams.Users = new HashMap<String, User>();
    GloableParams.ListGroupInfos = new ArrayList<GroupInfo>();
    GloableParams.GroupInfos = new HashMap<String, GroupInfo>();
    FinalDb db = FinalDb.create(this, Constants.DB_NAME, false);
    GloableParams.ListGroupInfos = db.findAll(GroupInfo.class);
    GloableParams.UserInfos = db.findAll(User.class);
}
Also used : User(com.juns.wechat.bean.User) GroupInfo(com.juns.wechat.bean.GroupInfo) FinalDb(net.tsz.afinal.FinalDb)

Example 3 with GroupInfo

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

the class Fragment_Msg method onItemClick.

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
    if (adpter.PublicMsg != null && position == 0) {
        // 打开订阅号列表页面
        Utils.start_Activity(getActivity(), PublishMsgListActivity.class);
    } else {
        ((MainActivity) getActivity()).updateUnreadLabel();
        EMConversation conversation = conversationList.get(position);
        Intent intent = new Intent(getActivity(), ChatActivity.class);
        Hashtable<String, String> ChatRecord = adpter.getChatRecord();
        if (ChatRecord != null) {
            if (conversation.isGroup()) {
                GroupInfo info = GloableParams.GroupInfos.get(conversation.getUserName());
                if (info != null) {
                    intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP);
                    intent.putExtra(Constants.GROUP_ID, info.getGroup_id());
                    // 设置标题
                    intent.putExtra(Constants.NAME, info.getGroup_name());
                    getActivity().startActivity(intent);
                } else {
                    intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP);
                    intent.putExtra(Constants.GROUP_ID, info.getGroup_id());
                    // 设置标题
                    intent.putExtra(Constants.NAME, R.string.group_chats);
                    getActivity().startActivity(intent);
                }
            } else {
                User user = GloableParams.Users.get(conversation.getUserName());
                if (user != null) {
                    // 设置昵称
                    intent.putExtra(Constants.NAME, user.getUserName());
                    intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
                    intent.putExtra(Constants.User_ID, conversation.getUserName());
                    getActivity().startActivity(intent);
                } else {
                    intent.putExtra(Constants.NAME, "好友");
                    intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_SINGLE);
                    intent.putExtra(Constants.User_ID, conversation.getUserName());
                    getActivity().startActivity(intent);
                }
            }
        }
    }
}
Also used : EMConversation(com.easemob.chat.EMConversation) User(com.juns.wechat.bean.User) GroupInfo(com.juns.wechat.bean.GroupInfo) Intent(android.content.Intent) MainActivity(com.juns.wechat.MainActivity)

Example 4 with GroupInfo

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

the class UpdateService method initGroupList.

// 获取群组列表
private void initGroupList() {
    GloableParams.ListGroupInfos = db.findAll(GroupInfo.class);
    netClient.post(Constants.getGroupListURL, null, new BaseJsonRes() {

        @Override
        public void onMySuccess(String data) {
            GloableParams.ListGroupInfos = JSON.parseArray(data, GroupInfo.class);
            for (GroupInfo group : GloableParams.ListGroupInfos) {
                if (db.findById(group.getId(), GroupInfo.class) != null)
                    db.deleteById(GroupInfo.class, group.getId());
                db.save(group);
                GloableParams.GroupInfos.put(group.getGroup_id(), group);
            }
            sendBrodcast("GroupList");
        }

        @Override
        public void onMyFailure() {
        // initGroupList();
        }
    });
}
Also used : GroupInfo(com.juns.wechat.bean.GroupInfo) BaseJsonRes(com.juns.wechat.net.BaseJsonRes)

Example 5 with GroupInfo

use of com.juns.wechat.bean.GroupInfo 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)

Aggregations

GroupInfo (com.juns.wechat.bean.GroupInfo)8 User (com.juns.wechat.bean.User)5 Intent (android.content.Intent)2 View (android.view.View)2 OnClickListener (android.view.View.OnClickListener)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 EMConversation (com.easemob.chat.EMConversation)2 EaseMobException (com.easemob.exceptions.EaseMobException)2 BaseJsonRes (com.juns.wechat.net.BaseJsonRes)2 FinalDb (net.tsz.afinal.FinalDb)2 EMGroup (com.easemob.chat.EMGroup)1 EMMessage (com.easemob.chat.EMMessage)1 RequestParams (com.juns.health.net.loopj.android.http.RequestParams)1 MainActivity (com.juns.wechat.MainActivity)1 ChatActivity (com.juns.wechat.chat.ChatActivity)1 WarnTipDialog (com.juns.wechat.dialog.WarnTipDialog)1 SwipeLayout (com.juns.wechat.widght.swipe.SwipeLayout)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1