当前位置: 首页>>代码示例>>Java>>正文


Java Friend类代码示例

本文整理汇总了Java中com.lqr.wechat.db.model.Friend的典型用法代码示例。如果您正苦于以下问题:Java Friend类的具体用法?Java Friend怎么用?Java Friend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Friend类属于com.lqr.wechat.db.model包,在下文中一共展示了Friend类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addGroupMembers

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
public void addGroupMembers() {
    ArrayList<String> selectedIds = new ArrayList<>(mSelectedData.size());
    for (int i = 0; i < mSelectedData.size(); i++) {
        Friend friend = mSelectedData.get(i);
        selectedIds.add(friend.getUserId());
    }
    Intent data = new Intent();
    data.putStringArrayListExtra("selectedIds", selectedIds);
    mContext.setResult(Activity.RESULT_OK, data);
    mContext.finish();
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:12,代码来源:CreateGroupAtPresenter.java

示例2: changeMyName

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
private void changeMyName() {
    showWaitingDialog(UIUtils.getString(R.string.please_wait));
    String nickName = mEtName.getText().toString().trim();
    ApiRetrofit.getInstance().setName(nickName)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(setNameResponse -> {
                hideWaitingDialog();
                if (setNameResponse.getCode() == 200) {
                    Friend friend = DBManager.getInstance().getFriendById(UserCache.getId());
                    if (friend != null) {
                        friend.setName(nickName);
                        friend.setDisplayName(nickName);
                        DBManager.getInstance().saveOrUpdateFriend(friend);
                        BroadcastManager.getInstance(ChangeMyNameActivity.this).sendBroadcast(AppConst.CHANGE_INFO_FOR_ME);
                        BroadcastManager.getInstance(ChangeMyNameActivity.this).sendBroadcast(AppConst.CHANGE_INFO_FOR_CHANGE_NAME);
                    }
                    finish();
                }
            }, this::loadError);
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:22,代码来源:ChangeMyNameActivity.java

示例3: saveFriends

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
public synchronized void saveFriends(List<UserRelationshipResponse.ResultEntity> list) {
    List<Friend> friends = new ArrayList<>();
    for (UserRelationshipResponse.ResultEntity entity : list) {
        if (entity.getStatus() == 20) {//已经是好友
            Friend friend = new Friend(
                    entity.getUser().getId(),
                    entity.getUser().getNickname(),
                    entity.getUser().getPortraitUri(),
                    TextUtils.isEmpty(entity.getDisplayName()) ? entity.getUser().getNickname() : entity.getDisplayName(),
                    null, null, null, null,
                    PinyinUtils.getPinyin(entity.getUser().getNickname()),
                    PinyinUtils.getPinyin(TextUtils.isEmpty(entity.getDisplayName()) ? entity.getUser().getNickname() : entity.getDisplayName())
            );
            if (TextUtils.isEmpty(friend.getPortraitUri())) {
                friend.setPortraitUri(getPortrait(friend));
            }
            friends.add(friend);
        }
    }
    if (friends != null && friends.size() > 0)
        DataSupport.saveAll(friends);
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:23,代码来源:DBManager.java

示例4: sortContacts

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
public static void sortContacts(List<Friend> list) {
    Collections.sort(list);//排序后由于#号排在上面,故得把#号的部分集合移动到集合的最下面
    List<Friend> specialList = new ArrayList<>();
    for (int i = 0; i < list.size(); i++) {
        //将属于#号的集合分离开来
        if (list.get(i).getNameSpelling().equalsIgnoreCase("#")) {
            specialList.add(list.get(i));
        }
    }

    if (specialList.size() != 0) {
        list.removeAll(specialList);//先移出掉顶部的#号部分
        list.addAll(list.size(), specialList);//将#号的集合添加到集合底部
    }

}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:17,代码来源:SortUtils.java

示例5: initListener

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
@Override
public void initListener() {
    mHeaderView.findViewById(R.id.llNewFriend).setOnClickListener(v -> {
        ((MainActivity) getActivity()).jumpToActivity(NewFriendActivity.class);
        ((MainActivity) getActivity()).mTvContactRedDot.setVisibility(View.GONE);
        mTvNewFriendUnread.setVisibility(View.GONE);
    });
    mHeaderView.findViewById(R.id.llGroup).setOnClickListener(v -> ((MainActivity) getActivity()).jumpToActivity(GroupListActivity.class));
    mQib.setOnLetterUpdateListener(new QuickIndexBar.OnLetterUpdateListener() {
        @Override
        public void onLetterUpdate(String letter) {
            //显示对话框
            showLetter(letter);
            //滑动到第一个对应字母开头的联系人
            if ("↑".equalsIgnoreCase(letter)) {
                mRvContacts.moveToPosition(0);
            } else if ("☆".equalsIgnoreCase(letter)) {
                mRvContacts.moveToPosition(0);
            } else {
                List<Friend> data = ((LQRAdapterForRecyclerView) ((LQRHeaderAndFooterAdapter) mRvContacts.getAdapter()).getInnerAdapter()).getData();
                for (int i = 0; i < data.size(); i++) {
                    Friend friend = data.get(i);
                    String c = friend.getDisplayNameSpelling().charAt(0) + "";
                    if (c.equalsIgnoreCase(letter)) {
                        mRvContacts.moveToPosition(i);
                        break;
                    }
                }
            }
        }

        @Override
        public void onLetterCancel() {
            //隐藏对话框
            hideLetter();
        }
    });
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:39,代码来源:ContactsFragment.java

示例6: agreeFriends

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
private void agreeFriends(String friendId, LQRViewHolderForRecyclerView helper) {
    if (!NetUtils.isNetworkAvailable(mContext)) {
        UIUtils.showToast(UIUtils.getString(R.string.please_check_net));
        return;
    }
    ApiRetrofit.getInstance().agreeFriends(friendId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .flatMap(new Func1<AgreeFriendsResponse, Observable<GetUserInfoByIdResponse>>() {
                @Override
                public Observable<GetUserInfoByIdResponse> call(AgreeFriendsResponse agreeFriendsResponse) {
                    if (agreeFriendsResponse != null && agreeFriendsResponse.getCode() == 200) {
                        helper.setViewVisibility(R.id.tvAdded, View.VISIBLE)
                                .setViewVisibility(R.id.btnAck, View.GONE);
                        return ApiRetrofit.getInstance().getUserInfoById(friendId);
                    }
                    return Observable.error(new ServerException(UIUtils.getString(R.string.agree_friend_fail)));
                }
            })
            .subscribe(getUserInfoByIdResponse -> {
                if (getUserInfoByIdResponse != null && getUserInfoByIdResponse.getCode() == 200) {
                    GetUserInfoByIdResponse.ResultEntity result = getUserInfoByIdResponse.getResult();
                    UserInfo userInfo = new UserInfo(UserCache.getId(), result.getNickname(), Uri.parse(result.getPortraitUri()));
                    if (TextUtils.isEmpty(userInfo.getPortraitUri().toString())) {
                        userInfo.setPortraitUri(Uri.parse(DBManager.getInstance().getPortraitUri(userInfo)));
                    }
                    Friend friend = new Friend(userInfo.getUserId(), userInfo.getName(), userInfo.getPortraitUri().toString());
                    DBManager.getInstance().saveOrUpdateFriend(friend);
                    UIUtils.postTaskDelay(() -> {
                        BroadcastManager.getInstance(UIUtils.getContext()).sendBroadcast(AppConst.UPDATE_FRIEND);
                        BroadcastManager.getInstance(UIUtils.getContext()).sendBroadcast(AppConst.UPDATE_CONVERSATIONS);
                    }, 1000);
                }
            }, this::loadError);
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:36,代码来源:NewFriendAtPresenter.java

示例7: setSelectedAdapter

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
private void setSelectedAdapter() {
    if (mSelectedAdapter == null) {
        mSelectedAdapter = new LQRAdapterForRecyclerView<Friend>(mContext, mSelectedData, R.layout.item_selected_contact) {
            @Override
            public void convert(LQRViewHolderForRecyclerView helper, Friend item, int position) {
                ImageView ivHeader = helper.getView(R.id.ivHeader);
                Glide.with(mContext).load(item.getPortraitUri()).centerCrop().into(ivHeader);
            }
        };
        getView().getRvSelectedContacts().setAdapter(mSelectedAdapter);
    }
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:13,代码来源:CreateGroupAtPresenter.java

示例8: deleteAllUserInfo

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
/**
     * 清除所有用户数据
     */
    public void deleteAllUserInfo() {
//        deleteFriends();
//        deleteGroups();
//        deleteGroupMembers();
        DataSupport.deleteAll(Friend.class);
        DataSupport.deleteAll(GroupMember.class);
        DataSupport.deleteAll(Groups.class);
        //TODO:删除黑名单数据
    }
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:13,代码来源:DBManager.java

示例9: isMyFriend

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
public boolean isMyFriend(String userid) {
    Friend friend = getFriendById(userid);
    if (friend != null) {
        return true;
    }
    return false;
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:8,代码来源:DBManager.java

示例10: saveOrUpdateFriend

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
public synchronized void saveOrUpdateFriend(Friend friend) {
    if (friend != null) {
        String portrait = friend.getPortraitUri();
        if (TextUtils.isEmpty(portrait)) {
            portrait = RongGenerate.generateDefaultAvatar(friend.getName(), friend.getUserId());
            friend.setPortraitUri(portrait);
        }
        friend.saveOrUpdate("userid = ?", friend.getUserId());
        //更新过本地好友数据后,清空内存中对应用户信息缓存
        if (mUserInfoCache != null && mUserInfoCache.containsKey(friend.getUserId())) {
            mUserInfoCache.remove(friend.getUserId());
        }
    }
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:15,代码来源:DBManager.java

示例11: getFriendById

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
public synchronized Friend getFriendById(String userid) {
    if (!TextUtils.isEmpty(userid)) {
        List<Friend> friends = DataSupport.where("userid = ?", userid).find(Friend.class);
        if (friends != null && friends.size() > 0)
            return friends.get(0);
    }
    return null;
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:9,代码来源:DBManager.java

示例12: setAdapter

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
private void setAdapter() {
    if (mAdapter == null) {
        LQRAdapterForRecyclerView adapter = new LQRAdapterForRecyclerView<Friend>(mContext, mData, R.layout.item_contact) {
            @Override
            public void convert(LQRViewHolderForRecyclerView helper, Friend item, int position) {
                helper.setText(R.id.tvName, item.getDisplayName());
                ImageView ivHeader = helper.getView(R.id.ivHeader);
                Glide.with(mContext).load(item.getPortraitUri()).centerCrop().into(ivHeader);

                String str = "";
                //得到当前字母
                String currentLetter = item.getDisplayNameSpelling().charAt(0) + "";
                if (position == 0) {
                    str = currentLetter;
                } else {
                    //得到上一个字母
                    String preLetter = mData.get(position - 1).getDisplayNameSpelling().charAt(0) + "";
                    //如果和上一个字母的首字母不同则显示字母栏
                    if (!preLetter.equalsIgnoreCase(currentLetter)) {
                        str = currentLetter;
                    }
                }
                int nextIndex = position + 1;
                if (nextIndex < mData.size() - 1) {
                    //得到下一个字母
                    String nextLetter = mData.get(nextIndex).getDisplayNameSpelling().charAt(0) + "";
                    //如果和下一个字母的首字母不同则隐藏下划线
                    if (!nextLetter.equalsIgnoreCase(currentLetter)) {
                        helper.setViewVisibility(R.id.vLine, View.INVISIBLE);
                    } else {
                        helper.setViewVisibility(R.id.vLine, View.VISIBLE);
                    }
                } else {
                    helper.setViewVisibility(R.id.vLine, View.INVISIBLE);
                }
                if (position == mData.size() - 1) {
                    helper.setViewVisibility(R.id.vLine, View.GONE);
                }

                //根据str是否为空决定字母栏是否显示
                if (TextUtils.isEmpty(str)) {
                    helper.setViewVisibility(R.id.tvIndex, View.GONE);
                } else {
                    helper.setViewVisibility(R.id.tvIndex, View.VISIBLE);
                    helper.setText(R.id.tvIndex, str);
                }
            }
        };
        adapter.addHeaderView(getView().getHeaderView());
        adapter.addFooterView(getView().getFooterView());
        mAdapter = adapter.getHeaderAndFooterAdapter();
        getView().getRvContacts().setAdapter(mAdapter);
    }
    ((LQRAdapterForRecyclerView) mAdapter.getInnerAdapter()).setOnItemClickListener((lqrViewHolder, viewGroup, view, i) -> {
        Intent intent = new Intent(mContext, UserInfoActivity.class);
        intent.putExtra("userInfo", DBManager.getInstance().getUserInfo(mData.get(i - 1).getUserId()));//-1是因为有头部
        mContext.jumpToActivity(intent);
    });
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:60,代码来源:ContactsFgPresenter.java

示例13: initListener

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
@Override
public void initListener() {
    mBtnToolbarSend.setOnClickListener(v -> {
        if (mSelectedTeamMemberAccounts == null) {
            mPresenter.createGroup();
        } else {
            //添加群成员
            mPresenter.addGroupMembers();
        }
    });
    mHeaderView.findViewById(R.id.tvSelectOneGroup).setOnClickListener(v -> UIUtils.showToast("选择一个群"));
    mQib.setOnLetterUpdateListener(new QuickIndexBar.OnLetterUpdateListener() {
        @Override
        public void onLetterUpdate(String letter) {
            //显示对话框
            showLetter(letter);
            //滑动到第一个对应字母开头的联系人
            if ("↑".equalsIgnoreCase(letter)) {
                mRvContacts.moveToPosition(0);
            } else if ("☆".equalsIgnoreCase(letter)) {
                mRvContacts.moveToPosition(0);
            } else {
                List<Friend> data = ((LQRAdapterForRecyclerView) ((LQRHeaderAndFooterAdapter) mRvContacts.getAdapter()).getInnerAdapter()).getData();
                for (int i = 0; i < data.size(); i++) {
                    Friend friend = data.get(i);
                    String c = friend.getDisplayNameSpelling().charAt(0) + "";
                    if (c.equalsIgnoreCase(letter)) {
                        mRvContacts.moveToPosition(i);
                        break;
                    }
                }
            }
        }

        @Override
        public void onLetterCancel() {
            //隐藏对话框
            hideLetter();
        }
    });
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:42,代码来源:CreateGroupActivity.java

示例14: deleteFriend

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
public synchronized void deleteFriend(Friend friend) {
    DataSupport.deleteAll(Friend.class, "userid = ?", friend.getUserId());
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:4,代码来源:DBManager.java

示例15: getFriends

import com.lqr.wechat.db.model.Friend; //导入依赖的package包/类
public synchronized List<Friend> getFriends() {
//        return DataSupport.findAll(Friend.class);
        return DataSupport.where("userid != ?", UserCache.getId()).find(Friend.class);
    }
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:5,代码来源:DBManager.java


注:本文中的com.lqr.wechat.db.model.Friend类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。