Search in sources :

Example 36 with UserBaseVo

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

the class SelectContactUI method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 0 && resultCode == RESULT_OK) {
        final String uid = data.getStringExtra("uid");
        final String avatarUrl = data.getStringExtra("avatarurl");
        final String username = data.getStringExtra("username");
        final String gender = data.getStringExtra("gender");
        UserBaseVo vo = new UserBaseVo();
        vo.setLocalId(uid);
        vo.setThumb(avatarUrl);
        vo.setUsername(username);
        vo.setGender(gender);
        clickSingleItem(vo);
    } else if (requestCode == 10 && resultCode == RESULT_OK) {
        final String uid = data.getStringExtra("uid");
        final String avatarUrl = data.getStringExtra("avatarurl");
        final String username = data.getStringExtra("username");
        final String gender = data.getStringExtra("gender");
        UserBaseVo vo = new UserBaseVo();
        vo.setLocalId(uid);
        vo.setThumb(avatarUrl);
        vo.setUsername(username);
        vo.setGender(gender);
        clickSingleItem(vo);
    } else if (requestCode == 100 && resultCode == RESULT_OK) {
        final String gid = data.getStringExtra("gid");
        final String avatarUrl = data.getStringExtra("avatarurl");
        final String username = data.getStringExtra("groupName");
        final String gender = data.getStringExtra("gender");
        UserBaseVo vo = new UserBaseVo();
        vo.setLocalId(gid);
        vo.setThumb(avatarUrl);
        vo.setUsername(username);
        vo.setGender(gender);
        clickSingleItem(vo);
    } else if (requestCode == 1000 && resultCode == RESULT_OK) {
        // Choose common contact back
        ArrayList<UserBaseVo> selectListT = (ArrayList<UserBaseVo>) data.getSerializableExtra("selectList");
        if (selectListT != null) {
            selectList.clear();
            selectList.addAll(selectListT);
            if (selectList.size() <= 0) {
                mFinishBtn.setEnabled(false);
            } else {
                mFinishBtn.setEnabled(true);
            }
            for (int i = 0; i < mContactList.size(); i++) {
                NewContactVO item = (NewContactVO) mContactList.get(i);
                boolean found = false;
                for (int m = 0; m < selectList.size(); m++) {
                    if (selectList.get(m).getLocalId().equals(item.getLocalId())) {
                        item.setChecked(true);
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    item.setChecked(false);
                }
            }
            mNewContactListAdapter.notifyDataSetChanged();
            mHorizontalScrollViewContent.removeAllViews();
            for (int i = 0; i < selectList.size(); i++) {
                final ImageView imageView = new ImageView(SelectContactUI.this);
                imageView.setTag(selectList.get(i).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, selectList.get(i).getThumb());
            }
            new Handler().postDelayed(new Runnable() {

                public void run() {
                    mHorizontalScrollView.smoothScrollTo(mHorizontalScrollViewContent.getChildCount() * Utils.dip2px(SelectContactUI.this, 50), 0);
                }
            }, 0);
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
Also used : NewContactVO(com.lingtuan.firefly.contact.vo.NewContactVO) ArrayList(java.util.ArrayList) 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)

Example 37 with UserBaseVo

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

the class SelectContactUI method clickSelectVo.

/*Click on the navigation bar at the bottom of a multiple-choice avatar to delete the user*/
private void clickSelectVo(ImageView imageView) {
    int count = mContactList.size();
    for (int i = 0; i < count; i++) {
        NewContactVO baseVo = (NewContactVO) mContactList.get(i);
        if (baseVo.getLocalId().equals(imageView.getTag())) {
            baseVo.setChecked(!baseVo.isChecked());
            mNewContactListAdapter.notifyDataSetChanged();
            if (mSearchAdapter != null) {
                mSearchAdapter.notifyDataSetChanged();
            }
            break;
        }
    }
    mHorizontalScrollViewContent.removeView(imageView);
    int selectCount = selectList.size();
    for (int i = 0; i < selectCount; i++) {
        UserBaseVo vo = selectList.get(i);
        if (vo.getLocalId().equals(imageView.getTag())) {
            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(imageView.getTag())) {
                hasSelectList.remove(i);
                break;
            }
        }
    }
}
Also used : NewContactVO(com.lingtuan.firefly.contact.vo.NewContactVO) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 38 with UserBaseVo

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

the class SelectGroupMemberListUI method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (position != 0) {
        UserBaseVo vo = mAdapter.getItem(position - 1);
        Intent data = new Intent();
        data.putExtra("data", vo);
        setResult(Activity.RESULT_OK, data);
        Utils.exitActivityAndBackAnim(this, true);
    } else {
        // TODO Search...
        if (!isSearch) {
            showSearch();
        } else {
            hideSearch();
        }
    }
}
Also used : Intent(android.content.Intent) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 39 with UserBaseVo

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

the class SelectGroupMemberListUI method parserJson.

private void parserJson(JSONObject response) {
    JSONObject jsonObject = response.optJSONObject("data");
    DiscussionGroupsVo vo = new DiscussionGroupsVo().parse(jsonObject, true);
    if (vo != null) {
        mAdapter.updateList(vo.getMembers());
        // Add a group of members The nickname and the uid data generated for @ function
        String[] usernames = new String[vo.getMembers().size()];
        String[] ids = new String[vo.getMembers().size()];
        for (int i = 0; i < vo.getMembers().size(); i++) {
            UserBaseVo uvo = vo.getMembers().get(i);
            usernames[i] = uvo.getUserName() + " ";
            ids[i] = uvo.getLocalId();
        }
        AtGroupParser.init(usernames, ids);
    }
}
Also used : JSONObject(org.json.JSONObject) DiscussionGroupsVo(com.lingtuan.firefly.contact.vo.DiscussionGroupsVo) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 40 with UserBaseVo

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

the class SelectGroupMemberListUI method initSearchData.

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<?> parent, View view, int position, long id) {
            UserBaseVo vo = mSearchAdapter.getItem(position);
            Intent data = new Intent();
            data.putExtra("data", vo);
            setResult(Activity.RESULT_OK, data);
            Utils.exitActivityAndBackAnim(SelectGroupMemberListUI.this, true);
            InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mInputSearch.getWindowToken(), 0);
        }
    });
    mEmpty = (TextView) findViewById(R.id.empty);
    mSearchListView.setEmptyView(mEmpty);
    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.setHint(R.string.search);
    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);
                } 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) {
                            e.printStackTrace();
                        }
                    }
                    curSearchTask = new SearchListTask();
                    curSearchTask.execute(searchString);
                }
            } else {
                searchListLayout.setVisibility(View.GONE);
            }
        }
    });
    mInputSearchCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            hideSearch();
        }
    });
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Intent(android.content.Intent) InputMethodManager(android.view.inputmethod.InputMethodManager) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) JSONException(org.json.JSONException) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) OnClickListener(android.view.View.OnClickListener) 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