Search in sources :

Example 11 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class ChatAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Holder h;
    final ChatMsg msg = mList.get(position);
    final int type = getItemViewType(position);
    if (convertView == null) {
        h = new Holder();
        switch(type) {
            case // The other side of the text information
            LEFT_TEXT:
                convertView = View.inflate(mContext, R.layout.item_chatting_left_text, null);
                break;
            case // The other side of the picture information
            LEFT_IMAGE:
                convertView = View.inflate(mContext, R.layout.item_chatting_left_image, null);
                break;
            case // Each other's voice messages
            LEFT_AUDIO:
                convertView = View.inflate(mContext, R.layout.item_chatting_left_audio, null);
                break;
            case // The other side of the business card information
            LEFT_CARD:
                convertView = View.inflate(mContext, R.layout.item_chatting_left_card, null);
                break;
            case // Share information
            LEFT_SHARE:
                convertView = View.inflate(mContext, R.layout.item_chatting_left_share, null);
                break;
            /**
             *----------------------------------------------------
             */
            case // His text message
            RIGHT_TEXT:
                convertView = View.inflate(mContext, R.layout.item_chatting_right_text, null);
                break;
            case // His picture information
            RIGHT_IMAGE:
                convertView = View.inflate(mContext, R.layout.item_chatting_right_image, null);
                break;
            case // His voice messages
            RIGHT_AUDIO:
                convertView = View.inflate(mContext, R.layout.item_chatting_right_audio, null);
                break;
            case // Your business card information
            RIGHT_CARD:
                convertView = View.inflate(mContext, R.layout.item_chatting_right_card, null);
                break;
            case // Share information
            RIGHT_SHARE:
                convertView = View.inflate(mContext, R.layout.item_chatting_right_share, null);
                break;
            case // The system informs the information
            NOTIF:
                convertView = View.inflate(mContext, R.layout.item_chatting_notif, null);
                break;
            case // Received the documents
            LEFT_SEND_FILE:
                convertView = View.inflate(mContext, R.layout.item_chatting_left_file, null);
                break;
            case // From the file
            RIGHT_SEND_FILE:
                convertView = View.inflate(mContext, R.layout.item_chatting_right_file, null);
                break;
        }
        h.leftLinear = (LinearLayout) convertView.findViewById(R.id.item_chatting_body_linear);
        h.imageUploadLinear = (LinearLayout) convertView.findViewById(R.id.item_chatting_image_upload_linear);
        h.avatar = (CharAvatarView) convertView.findViewById(R.id.item_chatting_avatar);
        h.mNickname = (TextView) convertView.findViewById(R.id.item_chatting_nickname);
        h.content = (TextView) convertView.findViewById(R.id.item_chatting_text);
        h.time = (TextView) convertView.findViewById(R.id.item_chatting_time);
        h.icon = (ImageView) convertView.findViewById(R.id.item_chatting_icon);
        h.msgWarnning = (ImageView) convertView.findViewById(R.id.item_chatting_warnning);
        h.msgImage = (ImageView) convertView.findViewById(R.id.item_chatting_image);
        h.mNotifBar = (ProgressBar) convertView.findViewById(R.id.item_chatting_notif);
        h.shopAddress = (TextView) convertView.findViewById(R.id.item_chatting_third_address);
        h.shopName = (TextView) convertView.findViewById(R.id.item_chatting_third_name);
        h.shopImage = (CharAvatarView) convertView.findViewById(R.id.item_chatting_third_avatar);
        h.audioTimes = (TextView) convertView.findViewById(R.id.item_chatting_audio_times);
        h.audioIcon = (ImageView) convertView.findViewById(R.id.item_chatting_audio_icon);
        h.selectBox = (ImageView) convertView.findViewById(R.id.item_chatting_select_iv);
        h.relativeLayout = (RelativeLayout) convertView.findViewById(R.id.relativelayout);
        /**
         ************************Documents related to****************************************
         */
        h.imgFileLogo = (ImageView) convertView.findViewById(R.id.img_file_logo);
        h.txtFileName = (TextView) convertView.findViewById(R.id.txt_file_name);
        h.txtFileSize = (TextView) convertView.findViewById(R.id.txt_file_size);
        h.txtFileSendState = (TextView) convertView.findViewById(R.id.txt_file_sent_state);
        h.progressbarFile = (ProgressBar) convertView.findViewById(R.id.file_send_progress);
        convertView.setTag(h);
    } else {
        h = (Holder) convertView.getTag();
    }
    if (h.selectBox != null) {
        if (delete || forwarding || isUpload) {
            h.selectBox.setVisibility(View.VISIBLE);
            int resId = selectedList.get(msg.getMessageId()) == null ? R.drawable.checkbox_unselected : R.drawable.checkbox_selected;
            h.selectBox.setImageResource(resId);
            if (h.relativeLayout != null) {
                h.relativeLayout.setVisibility(View.VISIBLE);
                h.relativeLayout.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        if (forwarding && (type == LEFT_SEND_FILE || type == RIGHT_SEND_FILE)) {
                            if (msg.getCreateTime() > 0) {
                                // One to one message file
                                long time = msg.getCreateTime() + 7 * 24 * 3600 - System.currentTimeMillis() / 1000;
                                if (time <= 0) {
                                    // Has the failure
                                    return;
                                }
                            }
                        }
                        // Voice is selected //Except upload chat logs
                        if (isUpload || !(forwarding && (type == LEFT_AUDIO || type == RIGHT_AUDIO || type == LEFT_DATIONG_SOS))) {
                            selectedItem(msg);
                        }
                    }
                });
            }
        } else {
            if (h.relativeLayout != null) {
                h.relativeLayout.setVisibility(View.GONE);
            }
            h.selectBox.setVisibility(View.GONE);
        }
    }
    switch(type) {
        // The other side of the text information
        case LEFT_TEXT:
        case // His text message
        RIGHT_TEXT:
            showTextMsg(h, msg, type);
            break;
        // The other side of the picture information
        case LEFT_IMAGE:
        case // His picture information
        RIGHT_IMAGE:
            showImgMsg(h, msg);
            break;
        // Each other's voice messages
        case LEFT_AUDIO:
        case // His voice messages
        RIGHT_AUDIO:
            setAudioContent(h, position, type);
            break;
        // The other side of the business card information
        case LEFT_CARD:
        case // Your business card information
        RIGHT_CARD:
            showCardMsg(h, msg);
            break;
        case // Send the file
        RIGHT_SEND_FILE:
            showFileInfo(h, msg, true);
            break;
        case // Received the documents
        LEFT_SEND_FILE:
            showFileInfo(h, msg, true);
            break;
        // Share information
        case LEFT_SHARE:
        case RIGHT_SHARE:
            showShareMsg(h, msg);
            break;
        case // The system informs the information
        NOTIF:
            showSystemMsg(h, msg);
            return convertView;
    }
    h.avatar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            UserBaseVo vo = new UserBaseVo();
            vo.setUsername(msg.getUsername());
            vo.setLocalId(msg.getUserId());
            vo.setThumb(msg.getUserImage());
            vo.setFriendLog(msg.getFriendLog());
            intentPeopleDetailUI(vo);
        }
    });
    h.avatar.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            if ((isGroup || TextUtils.equals(Constants.APP_EVERYONE, msg.getChatId()) || TextUtils.equals(Constants.APP_MESH, msg.getChatId())) && !msg.isMe() && mInputContent != null && mChattingManager != null) {
                // Long press head @ function
                int selectIndex = mInputContent.getSelectionStart();
                Editable mEditable = mInputContent.getEditableText();
                mEditable.insert(selectIndex, "@" + msg.getRealname() + " ");
                mChattingManager.sbAtGroupSelectIds.add(msg.getUserId());
                Utils.showKeyBoard(mInputContent);
                if (AtGroupParser.getInstance() == null) {
                    AtGroupParser.init(new String[] { msg.getRealname() + " " }, new String[] { msg.getUserId() });
                } else {
                    AtGroupParser.getInstance().addParse(msg.getRealname() + " ", msg.getUserId());
                }
            }
            return true;
        }
    });
    if (h.leftLinear != null) {
        h.leftLinear.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
                // Long chat content according to the event
                return onLongClickLogic(msg);
            }
        });
    }
    String url = "";
    if (msg.isMe()) {
        url = NextApplication.myInfo.getThumb();
    } else {
        url = msg.getUserImage();
        if (!TextUtils.isEmpty(tempAvatar.get(msg.getUserId()))) {
            url = tempAvatar.get(msg.getUserId());
        }
    }
    h.avatar.setText(msg.getUsername(), h.avatar, url);
    h.time.setVisibility(msg.isShowTime() ? View.VISIBLE : View.GONE);
    Utils.setLoginTime(mContext, h.time, msg.getMsgTime());
    if (h.mNickname != null) {
        if (!isGroup && !TextUtils.equals(Constants.APP_EVERYONE, msg.getChatId()) && !TextUtils.equals(Constants.APP_MESH, msg.getChatId())) {
            h.mNickname.setVisibility(View.GONE);
        } else {
            // group
            h.mNickname.setVisibility(View.VISIBLE);
            String name = msg.getUsername();
            if (!TextUtils.isEmpty(tempAvatar.get(msg.getUserId()))) {
                name = tempName.get(msg.getUserId());
            }
            h.mNickname.setText(name);
        }
    }
    return convertView;
}
Also used : OnLongClickListener(android.view.View.OnLongClickListener) Editable(android.text.Editable) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) CharAvatarView(com.lingtuan.firefly.custom.CharAvatarView) OnLongClickListener(android.view.View.OnLongClickListener) ChatMsg(com.lingtuan.firefly.vo.ChatMsg) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 12 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class DiscussGroupJoinUI method setContentView.

@Override
protected void setContentView() {
    setContentView(R.layout.discuss_group_join_layout);
    try {
        if (NextApplication.myInfo == null || TextUtils.isEmpty(NextApplication.myInfo.getLocalId())) {
            NextApplication.myInfo = new UserInfoVo().readMyUserInfo(this);
        }
        String s = getIntent().toURI();
        Uri parse = Uri.parse(s);
        String gid = parse.getQueryParameter("gid");
        if (!TextUtils.isEmpty(gid)) {
            cid = gid;
        } else {
            String uid = parse.getQueryParameter("uid");
            UserBaseVo info = new UserBaseVo();
            info.setLocalId(uid);
            if (!TextUtils.isEmpty(uid)) {
                Utils.intentFriendUserInfo(this, info, true);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Uri(android.net.Uri) UserInfoVo(com.lingtuan.firefly.vo.UserInfoVo) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 13 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class DiscussGroupMemberListUI method removeMemberChatMsg.

/**
 * Forge a delete members of the group chat message
 */
private void removeMemberChatMsg(final String name) {
    StringBuilder sb = new StringBuilder();
    int index = 1;
    for (UserBaseVo vo : data) {
        if (// Most need four pictures
        index > 4) {
            break;
        }
        sb.append(vo.getThumb()).append("___").append(vo.getGender()).append("#");
        index++;
    }
    sb.deleteCharAt(sb.lastIndexOf("#"));
    String url = sb.toString();
    ChatMsg chatmsg = new ChatMsg();
    chatmsg.setChatId("group-" + cid);
    chatmsg.setGroupName(name);
    chatmsg.setGroup(true);
    chatmsg.setType(14);
    chatmsg.setSend(1);
    chatmsg.setContent(getString(R.string.discuss_group_remove_other, name));
    chatmsg.setMsgTime(System.currentTimeMillis() / 1000);
    chatmsg.setMessageId(UUID.randomUUID().toString());
    chatmsg.parseUserBaseVo(NextApplication.myInfo.getUserBaseVo());
    Bundle bundle = new Bundle();
    bundle.putSerializable(XmppAction.ACTION_MESSAGE_LISTENER, chatmsg);
    Utils.intentAction(getApplicationContext(), XmppAction.ACTION_MESSAGE_LISTENER, bundle);
    FinalUserDataBase.getInstance().saveChatMsg(chatmsg, chatmsg.getChatId(), name, url, false);
}
Also used : Bundle(android.os.Bundle) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 14 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class DiscussGroupSettingUI method parseJson.

/*Parsing json*/
private void parseJson(JSONObject response) {
    JSONObject jsonObject = response.optJSONObject("data");
    DiscussionGroupsVo vo = new DiscussionGroupsVo().parse(jsonObject);
    nameEdit.setText(vo.getName());
    data.clear();
    showdata.clear();
    for (int i = 0; i < vo.getMembers().size(); i++) {
        UserBaseVo info = vo.getMembers().get(i);
        if (i == 0 && info.getLocalId().equals(NextApplication.myInfo.getLocalId())) {
            isAdmin = true;
        }
        data.add(info);
        if (isAdmin) {
            if (i <= 37) {
                showdata.add(info);
            }
        } else if (i <= 38) {
            showdata.add(info);
        }
    }
    if (isAdmin) {
        showdata.add(new UserBaseVo());
        showdata.add(new UserBaseVo());
        eidtNameBg.setClickable(true);
        dissmissBtn.setText(getResources().getString(R.string.group_dismiss_discussion));
    } else {
        showdata.add(new UserBaseVo());
        eidtNameBg.setClickable(false);
        dissmissBtn.setText(getResources().getString(R.string.group_out_discussion));
    }
    allNum.setText(getString(R.string.discuss_all, vo.getMembers().size()));
    switchBtn.setOnCheckedChangeListener(null);
    if (0 == vo.getMask()) {
        switchBtn.setChecked(false);
        switchBtn.setBackColor(getResources().getColorStateList(R.color.switch_button_gray));
    } else {
        switchBtn.setChecked(true);
        switchBtn.setBackColor(getResources().getColorStateList(R.color.switch_button_green));
        notifyClock.setVisibility(View.VISIBLE);
    }
    switchBtn.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                notifyClock.setVisibility(View.VISIBLE);
            } else {
                notifyClock.setVisibility(View.GONE);
            }
            if (isChecked) {
                switchBtn.setBackColor(getResources().getColorStateList(R.color.switch_button_green));
            } else {
                switchBtn.setBackColor(getResources().getColorStateList(R.color.switch_button_gray));
            }
            switchNotify();
        }
    });
    dissmissBtn.setVisibility(View.VISIBLE);
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) JSONObject(org.json.JSONObject) DiscussionGroupsVo(com.lingtuan.firefly.contact.vo.DiscussionGroupsVo) CompoundButton(android.widget.CompoundButton) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 15 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class DiscussGroupSettingUI method removeMember.

public void removeMember(final int arg2) {
    if (mProgressDialog != null) {
        mProgressDialog.dismiss();
        mProgressDialog = null;
    }
    mProgressDialog = LoadingDialog.showDialog(this, null, null);
    mProgressDialog.setCancelable(false);
    NetRequestImpl.getInstance().removeDiscussMember(showdata.get(arg2).getLocalId(), cid, new RequestListener() {

        @Override
        public void start() {
        }

        @Override
        public void success(JSONObject response) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
            showToast(response.optString("msg"));
            UserBaseVo user = showdata.get(arg2);
            data.remove(user);
            showdata.remove(user);
            removeMemberChatMsg(user.getShowName());
            resetlist();
        }

        @Override
        public void error(int errorCode, String errorMsg) {
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
            showToast(errorMsg);
        }
    });
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Aggregations

UserBaseVo (com.lingtuan.firefly.vo.UserBaseVo)53 ArrayList (java.util.ArrayList)13 ChatMsg (com.lingtuan.firefly.vo.ChatMsg)9 Cursor (android.database.Cursor)7 View (android.view.View)7 ListView (android.widget.ListView)7 TextView (android.widget.TextView)7 Intent (android.content.Intent)6 ImageView (android.widget.ImageView)6 JSONObject (org.json.JSONObject)6 Bundle (android.os.Bundle)5 AdapterView (android.widget.AdapterView)5 OnClickListener (android.view.View.OnClickListener)4 HorizontalScrollView (android.widget.HorizontalScrollView)4 DiscussionGroupsVo (com.lingtuan.firefly.contact.vo.DiscussionGroupsVo)4 NewContactVO (com.lingtuan.firefly.contact.vo.NewContactVO)4 RequestListener (com.lingtuan.firefly.listener.RequestListener)4 Handler (android.os.Handler)3 Editable (android.text.Editable)3 LinearLayout (android.widget.LinearLayout)3