Search in sources :

Example 16 with UserBaseVo

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

the class DiscussGroupSettingUI method inviteOthersChatMsg.

/**
 * Forge a invite others to join group chat message
 */
private void inviteOthersChatMsg(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(nameEdit.getText().toString());
    chatmsg.setGroup(true);
    chatmsg.setType(13);
    chatmsg.setSend(1);
    chatmsg.setContent(getString(R.string.discuss_group_invite_others, 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(), nameEdit.getText().toString(), url, false);
}
Also used : Bundle(android.os.Bundle) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo) ChatMsg(com.lingtuan.firefly.vo.ChatMsg)

Example 17 with UserBaseVo

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

the class DiscussGroupSettingUI method reNameChatMsg.

/**
 * Forge a system modification group chat information
 */
private void reNameChatMsg(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(17);
    chatmsg.setSend(1);
    chatmsg.setContent(getString(R.string.discuss_group_rename, chatmsg.getGroupName()));
    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 18 with UserBaseVo

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

the class RecommentContactListUI method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    UserBaseVo info = new UserBaseVo();
    info.setLocalId(mList.get(position).getUid());
    info.setUsername(mList.get(position).getUsername());
    info.setThumb(mList.get(position).getThumb());
    Utils.intentFriendUserInfo(this, info, false);
}
Also used : UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 19 with UserBaseVo

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

the class SelectContactUI method initSearchData.

/**
 *  Initializes the search related
 */
private void initSearchData(View headerView) {
    searchResultLayout = (LinearLayout) findViewById(R.id.contact_search_bg);
    searchResultLayout.setOnClickListener(this);
    searchListLayout = (FrameLayout) findViewById(R.id.contact_search_list_bg);
    mSearchListView = (ListView) findViewById(R.id.contact_search_lv);
    mSearchListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            UserBaseVo baseVo = mSearchAdapter.getItem(arg2);
            if (isMultipleChoice) {
                // multi-select
                if (baseVo.isCantChecked()) {
                    return;
                }
                baseVo.setChecked(!baseVo.isChecked());
                mSearchAdapter.notifyDataSetChanged();
                mNewContactListAdapter.notifyDataSetChanged();
                if (baseVo.isChecked()) {
                    final ImageView imageView = new ImageView(SelectContactUI.this);
                    imageView.setTag(baseVo.getLocalId());
                    imageView.setOnClickListener(new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            clickSelectVo(imageView);
                        }
                    });
                    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Utils.dip2px(SelectContactUI.this, 40), Utils.dip2px(SelectContactUI.this, 40));
                    lp.setMargins(Utils.dip2px(SelectContactUI.this, 10), Utils.dip2px(SelectContactUI.this, 5), 0, 0);
                    mHorizontalScrollViewContent.addView(imageView, lp);
                    NextApplication.displayCircleImage(imageView, baseVo.getThumb());
                    selectList.add(baseVo);
                    new Handler().postDelayed(new Runnable() {

                        public void run() {
                            mHorizontalScrollView.smoothScrollTo(mHorizontalScrollViewContent.getChildCount() * Utils.dip2px(SelectContactUI.this, 50), 0);
                        }
                    }, 0);
                    if (hasSelectList == null && !mFinishBtn.isEnabled()) {
                        mFinishBtn.setEnabled(true);
                    }
                    if (hasSelectList != null) {
                        // Over the selected user data
                        hasSelectList.add(baseVo);
                    }
                } else {
                    int count = mHorizontalScrollViewContent.getChildCount();
                    for (int i = 0; i < count; i++) {
                        View imageView = mHorizontalScrollViewContent.getChildAt(i);
                        if (baseVo.getLocalId().equals(imageView.getTag())) {
                            mHorizontalScrollViewContent.removeViewAt(i);
                            break;
                        }
                    }
                    for (int i = 0; i < selectList.size(); i++) {
                        if (selectList.get(i).getLocalId().equals(baseVo.getLocalId())) {
                            selectList.remove(i);
                            break;
                        }
                    }
                    if (hasSelectList == null && selectList.size() <= 0) {
                        if (mFinishBtn.isEnabled()) {
                            mFinishBtn.setEnabled(false);
                        }
                    }
                    if (hasSelectList != null) {
                        // Over the selected user data
                        int hasSelectCount = hasSelectList.size();
                        for (int i = 0; i < hasSelectCount; i++) {
                            UserBaseVo vo = hasSelectList.get(i);
                            if (vo.getLocalId().equals(baseVo.getLocalId())) {
                                hasSelectList.remove(i);
                                break;
                            }
                        }
                    }
                }
            } else {
                InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(mInputSearch.getWindowToken(), 0);
                clickSingleItem(baseVo);
            }
        }
    });
    mEmpty = (LinearLayout) findViewById(R.id.empty);
    mSearchListView.setEmptyView(mEmpty);
    mInTextView = (TextView) headerView.findViewById(R.id.include_friends_search_text);
    mInputSearch = (EditText) findViewById(R.id.include_friends_search_content);
    mInputSearchLayout = (LinearLayout) findViewById(R.id.include_friends_search_content_bg);
    mInputSearchCancel = (TextView) findViewById(R.id.include_friends_search_cancel);
    mInputSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

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

        @Override
        public synchronized void afterTextChanged(Editable s) {
            if (s != null) {
                friendFilterList.clear();
                if (s.toString().length() <= 0) {
                    searchListLayout.setVisibility(View.GONE);
                    searchResultLayout.setOnClickListener(SelectContactUI.this);
                } else {
                    searchListLayout.setVisibility(View.VISIBLE);
                    searchResultLayout.setOnClickListener(null);
                    String searchString = s.toString().toUpperCase();
                    if (curSearchTask != null && curSearchTask.getStatus() != AsyncTask.Status.FINISHED) {
                        try {
                            curSearchTask.cancel(true);
                        } catch (Exception e) {
                        }
                    }
                    curSearchTask = new SearchListTask();
                    curSearchTask.execute(searchString);
                }
            } else {
                searchListLayout.setVisibility(View.GONE);
                searchResultLayout.setOnClickListener(SelectContactUI.this);
            }
        }
    });
    mInputSearchCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            hideSearch();
        }
    });
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Handler(android.os.Handler) InputMethodManager(android.view.inputmethod.InputMethodManager) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnClickListener(android.view.View.OnClickListener) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 20 with UserBaseVo

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

the class SelectContactUI method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (position >= mContactList.size() + 1) {
        return;
    } else if (position == 0) {
        showSearch();
        return;
    }
    if (isMultipleChoice) {
        // multi-select
        NewContactVO baseVo = (NewContactVO) mContactList.get(position - 1);
        if (baseVo.isCantChecked()) {
            return;
        }
        baseVo.setChecked(!baseVo.isChecked());
        mNewContactListAdapter.notifyDataSetChanged();
        if (baseVo.isChecked()) {
            final ImageView imageView = new ImageView(SelectContactUI.this);
            imageView.setTag(baseVo.getLocalId());
            imageView.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    clickSelectVo(imageView);
                }
            });
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Utils.dip2px(SelectContactUI.this, 40), Utils.dip2px(SelectContactUI.this, 40));
            lp.setMargins(Utils.dip2px(SelectContactUI.this, 10), Utils.dip2px(SelectContactUI.this, 5), 0, 0);
            mHorizontalScrollViewContent.addView(imageView, lp);
            NextApplication.displayCircleImage(imageView, baseVo.getThumb());
            selectList.add(baseVo);
            new Handler().postDelayed(new Runnable() {

                public void run() {
                    mHorizontalScrollView.smoothScrollTo(mHorizontalScrollViewContent.getChildCount() * Utils.dip2px(SelectContactUI.this, 50), 0);
                }
            }, 0);
            if (hasSelectList == null && !mFinishBtn.isEnabled()) {
                mFinishBtn.setEnabled(true);
            }
            if (hasSelectList != null) {
                hasSelectList.add(baseVo);
            }
        } else {
            for (int i = 0; i < mHorizontalScrollViewContent.getChildCount(); i++) {
                View imageView = mHorizontalScrollViewContent.getChildAt(i);
                if (baseVo.getLocalId().equals(imageView.getTag())) {
                    mHorizontalScrollViewContent.removeViewAt(i);
                    break;
                }
            }
            for (int i = 0; i < selectList.size(); i++) {
                if (selectList.get(i).getLocalId().equals(baseVo.getLocalId())) {
                    selectList.remove(i);
                    break;
                }
            }
            if (hasSelectList == null && selectList.size() <= 0) {
                if (mFinishBtn.isEnabled()) {
                    mFinishBtn.setEnabled(false);
                }
            }
            if (hasSelectList != null) {
                int hasSelectCount = hasSelectList.size();
                for (int i = 0; i < hasSelectCount; i++) {
                    UserBaseVo vo = hasSelectList.get(i);
                    if (vo.getLocalId().equals(baseVo.getLocalId())) {
                        hasSelectList.remove(i);
                        break;
                    }
                }
            }
        }
    } else {
        NewContactVO baseVo = (NewContactVO) mContactList.get(position - 1);
        clickSingleItem(baseVo);
    }
}
Also used : NewContactVO(com.lingtuan.firefly.contact.vo.NewContactVO) OnClickListener(android.view.View.OnClickListener) Handler(android.os.Handler) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) LinearLayout(android.widget.LinearLayout) 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