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


Java DBManager类代码示例

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


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

示例1: setAdapter

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
private void setAdapter() {
    if (mAdapter == null) {
        mAdapter = new LQRAdapterForRecyclerView<Groups>(mContext, mData, R.layout.item_contact) {
            @Override
            public void convert(LQRViewHolderForRecyclerView helper, Groups item, int position) {
                LQRNineGridImageView ngvi = helper.setViewVisibility(R.id.ngiv, View.VISIBLE)
                        .setViewVisibility(R.id.ivHeader, View.GONE)
                        .setText(R.id.tvName, item.getName())
                        .getView(R.id.ngiv);
                ngvi.setAdapter(mNgivAdapter);
                List<GroupMember> groupMembers = DBManager.getInstance().getGroupMembers(item.getGroupId());
                ngvi.setImagesData(groupMembers);
            }
        };
        mAdapter.setOnItemClickListener((lqrViewHolder, viewGroup, view, i) -> {
            Intent intent = new Intent(mContext, SessionActivity.class);
            intent.putExtra("sessionId", mData.get(i).getGroupId());
            intent.putExtra("sessionType", SessionActivity.SESSION_TYPE_GROUP);
            mContext.jumpToActivity(intent);
            mContext.finish();
        });
        getView().getRvGroupList().setAdapter(mAdapter);
    } else {
        mAdapter.notifyDataSetChangedWrapper();
    }
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:27,代码来源:GroupListAtPresenter.java

示例2: loadOtherInfo

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
public void loadOtherInfo(int sessionType, String sessionId) {
    setToTop();
    switch (sessionType) {
        case SESSION_TYPE_PRIVATE:

            break;
        case SESSION_TYPE_GROUP:
            Observable.just(DBManager.getInstance().getGroupsById(sessionId))
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(groups -> {
                        if (groups == null)
                            return;
                        mGroups = groups;
                        //设置群信息
                        getView().getOivGroupName().setRightText(groups.getName());
                        mDisplayName = TextUtils.isEmpty(groups.getDisplayName()) ?
                                DBManager.getInstance().getUserInfo(UserCache.getId()).getName() :
                                groups.getDisplayName();
                        getView().getOivNickNameInGroup().setRightText(mDisplayName);
                        getView().getBtnQuit().setText(groups.getRole().equals("0") ? UIUtils.getString(R.string.dismiss_this_group) :
                                UIUtils.getString(R.string.delete_and_exit));
                    }, this::loadOtherError);
            break;
    }
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:27,代码来源:SessionInfoAtPresenter.java

示例3: loadData

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
private void loadData() {
    Observable.just(DBManager.getInstance().getFriends())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(friends -> {
                if (friends != null && friends.size() > 0) {
                    mData.clear();
                    mData.addAll(friends);
                    getView().getFooterView().setText(UIUtils.getString(R.string.count_of_contacts, mData.size()));
                    //整理排序
                    SortUtils.sortContacts(mData);
                    if (mAdapter != null)
                        mAdapter.notifyDataSetChanged();
                }
            }, this::loadError);
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:17,代码来源:ContactsFgPresenter.java

示例4: changeMyName

import com.lqr.wechat.db.DBManager; //导入依赖的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

示例5: initData

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
@Override
public void initData() {
    List<GroupMember> groupMembers = DBManager.getInstance().getGroupMembers(mGroupId);
    if (groupMembers != null && groupMembers.size() > 0) {
        for (int i = 0; i < groupMembers.size(); i++) {
            GroupMember groupMember = groupMembers.get(i);
            if (groupMember.getUserId().equals(UserCache.getId())) {
                groupMembers.remove(i);
                break;
            }
        }
        mData.clear();
        mData.addAll(groupMembers);
    }
    setAdapter();
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:17,代码来源:RemoveGroupMemberActivity.java

示例6: setOnClick

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
private void setOnClick(LQRViewHolderForRecyclerView helper, Message item, int position) {
    helper.getView(R.id.llError).setOnClickListener(v ->
            RongIMClient.getInstance().deleteMessages(new int[]{item.getMessageId()}, new RongIMClient.ResultCallback<Boolean>() {
                @Override
                public void onSuccess(Boolean aBoolean) {
                    mData.remove(position);
                    mPresenter.setAdapter();
                    MessageContent content = item.getContent();
                    if (content instanceof TextMessage) {
                        mPresenter.sendTextMsg(((TextMessage) content).getContent());
                    } else if (content instanceof ImageMessage) {
                        mPresenter.sendImgMsg(((ImageMessage) content).getThumUri(), ((ImageMessage) content).getLocalUri());
                    } else if (content instanceof FileMessage) {
                        mPresenter.sendFileMsg(new File(((FileMessage) content).getLocalPath().getPath()));
                    } else if (content instanceof VoiceMessage) {
                        VoiceMessage voiceMessage = (VoiceMessage) content;
                        mPresenter.sendAudioFile(voiceMessage.getUri(), voiceMessage.getDuration());
                    }
                }

                @Override
                public void onError(RongIMClient.ErrorCode errorCode) {

                }
            })
    );
    helper.getView(R.id.ivAvatar).setOnClickListener(v -> {
        UserInfo userInfo = DBManager.getInstance().getUserInfo(item.getSenderUserId());
        if (userInfo != null) {
            Intent intent = new Intent(mContext, UserInfoActivity.class);
            intent.putExtra("userInfo", userInfo);
            ((SessionActivity) mContext).jumpToActivity(intent);
        }
    });
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:36,代码来源:SessionAdapter.java

示例7: setAvatar

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
private void setAvatar(LQRViewHolderForRecyclerView helper, Message item, int position) {
    ImageView ivAvatar = helper.getView(R.id.ivAvatar);
    UserInfo userInfo = DBManager.getInstance().getUserInfo(item.getSenderUserId());
    if (userInfo != null) {
        Glide.with(mContext).load(userInfo.getPortraitUri()).centerCrop().into(ivAvatar);
    }
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:8,代码来源:SessionAdapter.java

示例8: filterData

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
private void filterData(List<Conversation> conversations) {
    for (int i = 0; i < conversations.size(); i++) {
        Conversation item = conversations.get(i);
        //其他消息会话不显示(比如:系统消息)
        if (!(item.getConversationType() == Conversation.ConversationType.PRIVATE || item.getConversationType() == Conversation.ConversationType.GROUP)) {
            conversations.remove(i);
            i--;
            continue;
        }
        if (item.getConversationType() == Conversation.ConversationType.GROUP) {
            List<GroupMember> groupMembers = DBManager.getInstance().getGroupMembers(item.getTargetId());
            if (groupMembers == null || groupMembers.size() == 0) {
                DBManager.getInstance().deleteGroupsById(item.getTargetId());//删除没有群成员的群
                conversations.remove(i);
                i--;
            }
        } else if (item.getConversationType() == Conversation.ConversationType.PRIVATE) {
            if (!DBManager.getInstance().isMyFriend(item.getTargetId())) {
                conversations.remove(i);
                i--;
            }
        }
    }
    mUnreadCountTotal = 0;
    for (Conversation conversation : conversations) {
        mUnreadCountTotal += conversation.getUnreadMessageCount();
    }
    updateTotalUnreadView();
    if (mAdapter != null)
        mAdapter.notifyDataSetChangedWrapper();
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:32,代码来源:RecentMessageFgPresenter.java

示例9: loadData

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
private void loadData() {
    List<Groups> groups = DBManager.getInstance().getGroups();
    if (groups != null && groups.size() > 0) {
        mData.clear();
        mData.addAll(groups);
        setAdapter();
        getView().getLlGroups().setVisibility(View.VISIBLE);
    } else {
        getView().getLlGroups().setVisibility(View.GONE);
    }
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:12,代码来源:GroupListAtPresenter.java

示例10: sendRedPacketMsg

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
public void sendRedPacketMsg() {
    if (mConversationType == Conversation.ConversationType.PRIVATE) {
        UserInfo userInfo = DBManager.getInstance().getUserInfo(mSessionId);
        if (userInfo != null)
            RedPacketUtil.startRedPacket(mContext, userInfo, RPSendPacketCallback);
    } else {
        List<GroupMember> groupMembers = DBManager.getInstance().getGroupMembers(mSessionId);
        if (groupMembers != null)
            RedPacketUtil.startRedPacket(mContext, mSessionId, groupMembers.size(), RPSendPacketCallback);
    }
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:12,代码来源:SessionAtPresenter.java

示例11: loadUserInfo

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
public void loadUserInfo() {
    mUserInfo = DBManager.getInstance().getUserInfo(UserCache.getId());
    if (mUserInfo != null) {
        Glide.with(mContext).load(mUserInfo.getPortraitUri()).centerCrop().into(getView().getIvHeader());
        getView().getOivName().setRightText(mUserInfo.getName());
        getView().getOivAccount().setRightText(mUserInfo.getUserId());
    }
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:9,代码来源:MyInfoAtPresenter.java

示例12: setAdapter

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
private void setAdapter() {
    if (mAdapter == null) {
        mAdapter = new LQRAdapterForRecyclerView<UserRelationshipResponse.ResultEntity>(mContext, mData, R.layout.item_new_friends) {
            @Override
            public void convert(LQRViewHolderForRecyclerView helper, UserRelationshipResponse.ResultEntity item, int position) {

                ImageView ivHeader = helper.getView(R.id.ivHeader);
                helper.setText(R.id.tvName, item.getUser().getNickname())
                        .setText(R.id.tvMsg, item.getMessage());

                if (item.getStatus() == 20) {//已经是好友
                    helper.setViewVisibility(R.id.tvAdded, View.VISIBLE)
                            .setViewVisibility(R.id.tvWait, View.GONE)
                            .setViewVisibility(R.id.btnAck, View.GONE);
                } else if (item.getStatus() == 11) {//别人发来的添加好友请求
                    helper.setViewVisibility(R.id.tvAdded, View.GONE)
                            .setViewVisibility(R.id.tvWait, View.GONE)
                            .setViewVisibility(R.id.btnAck, View.VISIBLE);
                } else if (item.getStatus() == 10) {//我发起的添加好友请求
                    helper.setViewVisibility(R.id.tvAdded, View.GONE)
                            .setViewVisibility(R.id.tvWait, View.VISIBLE)
                            .setViewVisibility(R.id.btnAck, View.GONE);
                }

                String portraitUri = item.getUser().getPortraitUri();
                if (TextUtils.isEmpty(portraitUri)) {
                    portraitUri = DBManager.getInstance().getPortraitUri(item.getUser().getNickname(), item.getUser().getId());
                }
                Glide.with(mContext).load(portraitUri).centerCrop().into(ivHeader);
                helper.getView(R.id.btnAck).setOnClickListener(v -> agreeFriends(item.getUser().getId(), helper));

            }
        };
    }
    getView().getRvNewFriend().setAdapter(mAdapter);
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:37,代码来源:NewFriendAtPresenter.java

示例13: agreeFriends

import com.lqr.wechat.db.DBManager; //导入依赖的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

示例14: loadData

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
private void loadData() {
    Observable.just(DBManager.getInstance().getFriends())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(friends -> {
                if (friends != null && friends.size() > 0) {
                    mData.clear();
                    mData.addAll(friends);
                    //整理排序
                    SortUtils.sortContacts(mData);
                    if (mAdapter != null)
                        mAdapter.notifyDataSetChanged();
                }
            }, this::loadError);
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:16,代码来源:CreateGroupAtPresenter.java

示例15: loadData

import com.lqr.wechat.db.DBManager; //导入依赖的package包/类
private void loadData() {
    if (mConversationType == Conversation.ConversationType.PRIVATE) {
        UserInfo userInfo = DBManager.getInstance().getUserInfo(mSessionId);
        if (userInfo != null) {
            mData.clear();
            GroupMember newMember = new GroupMember(mSessionId,
                    userInfo.getUserId(),
                    userInfo.getName(),
                    userInfo.getPortraitUri().toString(),
                    userInfo.getName(),
                    PinyinUtils.getPinyin(userInfo.getName()),
                    PinyinUtils.getPinyin(userInfo.getName()),
                    "",
                    "",
                    "");
            mData.add(newMember);
            mData.add(new GroupMember("", "", ""));//+
        }
        mIsCreateNewGroup = true;
    } else {
        List<GroupMember> groupMembers = DBManager.getInstance().getGroupMembers(mSessionId);
        if (groupMembers != null && groupMembers.size() > 0) {
            Groups groupsById = DBManager.getInstance().getGroupsById(mSessionId);
            if (groupsById != null && groupsById.getRole().equals("0")) {
                mIsManager = true;
            }
            mData.clear();
            mData.addAll(groupMembers);
            mData.add(new GroupMember("", "", ""));//+
            if (mIsManager) {
                mData.add(new GroupMember("", "", ""));//-
            }
        }
        mIsCreateNewGroup = false;
    }
    setAdapter();
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:38,代码来源:SessionInfoAtPresenter.java


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