Search in sources :

Example 1 with UserBaseVo

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

the class MainContactFragmentUI method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 0 && resultCode == getActivity().RESULT_OK) {
        // Select the contact to return
        ArrayList<UserBaseVo> selectList = (ArrayList<UserBaseVo>) data.getSerializableExtra("selectList");
        if (selectList != null && selectList.size() == 1) {
            UserBaseVo vo = selectList.get(0);
            Utils.intentChattingUI(getActivity(), vo.getLocalId(), vo.getThumb(), vo.getShowName(), vo.getGender(), vo.getFriendLog(), false, false, false, 0, false);
        } else if (selectList != null && selectList.size() > 1) {
            StringBuilder touids = new StringBuilder();
            for (UserBaseVo vo : selectList) {
                touids.append(vo.getLocalId()).append(",");
            }
            touids.deleteCharAt(touids.lastIndexOf(","));
            createDiscussionGroups(touids.toString(), selectList);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 2 with UserBaseVo

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

the class MainContactFragmentUI method deleteFriends.

/**
 * Remove buddy
 */
private void deleteFriends(final String uid, final boolean isFriendOffline) {
    if (isFriendOffline) {
        FinalUserDataBase.getInstance().deleteFriendByUid(uid);
        int i = 0;
        for (UserBaseVo info : mFriendInfoList) {
            if (uid.equals(info.getLocalId())) {
                mFriendInfoList.remove(i);
                break;
            }
            i++;
        }
        mContactList.clear();
        for (UserBaseVo voT : mFriendInfoList) {
            NewContactVO info = new NewContactVO();
            info.setAge(voT.getAge());
            info.setDistance(voT.getDistance());
            info.setFriendLog(voT.getFriendLog());
            info.setGender(voT.getGender());
            info.setSightml(voT.getSightml());
            info.setThumb(voT.getThumb());
            info.setLocalId(voT.getLocalId());
            info.setUsername(voT.getUserName());
            info.setNote(voT.getNote());
            info.setLogintime(voT.getLogintime());
            info.setFullName(PinYin.getPinYin(voT.getShowName()));
            info.setMid(voT.getMid());
            info.setOffLine(voT.isOffLine());
            mContactList.add(info);
        }
        mNewListView.setFastScrollEnabled(true);
        Collections.sort(mContactList, new ContactItemComparator());
        mNewContactListAdapter.updateList(mContactList);
        contactNum.setText(getString(R.string.contact_num, mContactList.size()));
    } else {
        NetRequestImpl.getInstance().deleteFriends(uid, new RequestListener() {

            @Override
            public void start() {
            }

            @Override
            public void success(JSONObject response) {
                showToast(response.optString("msg"));
                FinalUserDataBase.getInstance().deleteFriendByUid(uid);
                int i = 0;
                for (UserBaseVo info : mFriendInfoList) {
                    if (uid.equals(info.getLocalId())) {
                        mFriendInfoList.remove(i);
                        break;
                    }
                    i++;
                }
                mContactList.clear();
                for (UserBaseVo voT : mFriendInfoList) {
                    NewContactVO info = new NewContactVO();
                    info.setAge(voT.getAge());
                    info.setDistance(voT.getDistance());
                    info.setFriendLog(voT.getFriendLog());
                    info.setGender(voT.getGender());
                    info.setSightml(voT.getSightml());
                    info.setThumb(voT.getThumb());
                    info.setLocalId(voT.getLocalId());
                    info.setUsername(voT.getUserName());
                    info.setNote(voT.getNote());
                    info.setLogintime(voT.getLogintime());
                    info.setFullName(PinYin.getPinYin(voT.getShowName()));
                    info.setMid(voT.getMid());
                    info.setOffLine(voT.isOffLine());
                    mContactList.add(info);
                }
                mNewListView.setFastScrollEnabled(true);
                Collections.sort(mContactList, new ContactItemComparator());
                mNewContactListAdapter.updateList(mContactList);
                contactNum.setText(getString(R.string.contact_num, mContactList.size()));
            }

            @Override
            public void error(int errorCode, String errorMsg) {
                showToast(errorMsg);
            }
        });
    }
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) NewContactVO(com.lingtuan.firefly.contact.vo.NewContactVO) ContactItemComparator(com.lingtuan.firefly.custom.contact.ContactItemComparator) SuppressLint(android.annotation.SuppressLint) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 3 with UserBaseVo

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

the class MainFoundFragmentUI method onRadarItemClick.

@Override
public void onRadarItemClick(int position) {
    WifiPeopleVO wifiPeopleVO = mDatas.get(position);
    UserBaseVo info = new UserBaseVo();
    info.setLocalId(wifiPeopleVO.getLocalId());
    info.setMid(wifiPeopleVO.getMid());
    info.setUsername(wifiPeopleVO.getUserName());
    info.setNote(wifiPeopleVO.getNote());
    info.setThumb(wifiPeopleVO.getThumb());
    info.setGender(wifiPeopleVO.getGender());
    info.setSightml(wifiPeopleVO.getSightml());
    info.setAge(wifiPeopleVO.getAge());
    info.setFriendLog(wifiPeopleVO.getFriendLog());
    info.setOffLineFound(true);
    Utils.intentFriendUserInfo(getActivity(), info, false);
}
Also used : WifiPeopleVO(com.lingtuan.firefly.offline.vo.WifiPeopleVO) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 4 with UserBaseVo

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

the class FinalUserDataBase method getOffLineInfoByUid.

/**
 * Get offline user information
 *
 * @param uid The user id
 */
public WifiPeopleVO getOffLineInfoByUid(String uid) {
    if (TextUtils.isEmpty(uid)) {
        return null;
    }
    String sql = "select * from " + TableField.TABLE_FRIEND + " where " + TableField.FIELD_FRIEND_UID + "=? and " + TableField.FIELD_RESERVED_DATA3 + "=1";
    Cursor cursor = db.rawQuery(sql, new String[] { uid });
    WifiPeopleVO vo = null;
    if (cursor.moveToNext()) {
        vo = new WifiPeopleVO();
        vo.setAge(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_AGE)));
        vo.setDistance(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_DISTANCE)));
        vo.setGender(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_GENDER)));
        vo.setLogintime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_FRIEND_LOGINTIME)));
        vo.setNote(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_NOTE)));
        vo.setPic(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_PIC)));
        vo.setSightml(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_SIGHTML)));
        vo.setThumb(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_THUMB)));
        vo.setLocalId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
        vo.setUsername(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
        vo.setOffLine(true);
        vo.setMeetNum(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA4)));
        vo.setAddress(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA7)));
        UserBaseVo baseVo = getUserBaseVoByUid(uid);
        if (baseVo != null) {
            vo.setFriendLog(1);
        }
    }
    cursor.close();
    return vo;
}
Also used : WifiPeopleVO(com.lingtuan.firefly.offline.vo.WifiPeopleVO) Cursor(android.database.Cursor) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 5 with UserBaseVo

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

the class FinalUserDataBase method clearFriends.

public void clearFriends(List<UserBaseVo> mFriendInfoList) {
    String sql = "select * from " + TableField.TABLE_FRIEND + " order by " + TableField.FIELD_FRIEND_UID;
    Cursor cursor = db.rawQuery(sql, null);
    UserBaseVo vo;
    while (cursor.moveToNext()) {
        vo = new UserBaseVo();
        vo.setLocalId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
        vo.setOffLine(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA3)) == 1 ? true : false);
        if (vo.isOffLine()) {
            boolean hasSynced = false;
            for (int i = 0; i < mFriendInfoList.size(); i++) {
                if (mFriendInfoList.get(i).getLocalId().equals(vo.getLocalId())) {
                    hasSynced = true;
                }
            }
            if (hasSynced) {
                db.delete(TableField.TABLE_FRIEND, TableField.FIELD_FRIEND_UID + "=?", new String[] { vo.getLocalId() });
            }
        } else {
            db.delete(TableField.TABLE_FRIEND, TableField.FIELD_FRIEND_UID + "=?", new String[] { vo.getLocalId() });
        }
    }
    cursor.close();
// db.delete(TableField.TABLE_FRIEND, null, null);
}
Also used : Cursor(android.database.Cursor) 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