當前位置: 首頁>>代碼示例>>Java>>正文


Java ApiRetrofit類代碼示例

本文整理匯總了Java中com.lqr.wechat.api.ApiRetrofit的典型用法代碼示例。如果您正苦於以下問題:Java ApiRetrofit類的具體用法?Java ApiRetrofit怎麽用?Java ApiRetrofit使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ApiRetrofit類屬於com.lqr.wechat.api包,在下文中一共展示了ApiRetrofit類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: changeMyName

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的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

示例2: fetchFriends

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
/**
 * 同步朋友信息
 */
private void fetchFriends() {
    mHasFetchedFriends = false;
    ApiRetrofit.getInstance().getAllUserRelationship()
            .subscribeOn(Schedulers.io())
            .observeOn(Schedulers.io())
            .subscribe(userRelationshipResponse -> {
                if (userRelationshipResponse != null && userRelationshipResponse.getCode() == 200) {
                    List<UserRelationshipResponse.ResultEntity> list = userRelationshipResponse.getResult();
                    if (list != null && list.size() > 0) {
                        deleteFriends();
                        saveFriends(list);
                    }
                    mHasFetchedFriends = true;
                    checkFetchComplete();
                } else {
                    mHasFetchedFriends = true;
                    checkFetchComplete();
                }
            }, this::fetchFriendError);
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:24,代碼來源:DBManager.java

示例3: fetchGroups

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
/**
 * 同步群組信息
 */
private void fetchGroups() {
    mHasFetchedGroups = false;
    ApiRetrofit.getInstance().getGroups()
            .subscribeOn(Schedulers.io())
            .observeOn(Schedulers.io())
            .subscribe(getGroupResponse -> {
                if (getGroupResponse != null && getGroupResponse.getCode() == 200) {
                    List<GetGroupResponse.ResultEntity> list = getGroupResponse.getResult();
                    if (list != null && list.size() > 0) {
                        deleteGroups();
                        saveGroups(list);
                        //同步群組成員信息
                        fetchGroupMembers();
                    } else {
                        mHasFetchedGroupMembers = true;
                    }
                    mHasFetchedGroups = true;
                    checkFetchComplete();
                } else {
                    mHasFetchedGroups = true;
                    mHasFetchedGroupMembers = true;
                    checkFetchComplete();
                }
            }, this::fetchGroupsError);
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:29,代碼來源:DBManager.java

示例4: fetchGroupMembers

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
/**
 * 同步群組成員信息
 */
private void fetchGroupMembers() {
    mHasFetchedGroupMembers = false;
    Observable.from(getGroups())
            .subscribeOn(Schedulers.io())
            .observeOn(Schedulers.io())
            .subscribe(groups ->
                    ApiRetrofit.getInstance().getGroupMember(groups.getGroupId())
                            .subscribe(getGroupMemberResponse -> {
                                if (getGroupMemberResponse != null && getGroupMemberResponse.getCode() == 200) {
                                    List<GetGroupMemberResponse.ResultEntity> list = getGroupMemberResponse.getResult();
                                    if (list != null && list.size() > 0) {
                                        deleteGroupMembersByGroupId(groups.getGroupId());
                                        saveGroupMembers(list, groups.getGroupId());
                                    }
                                    mHasFetchedGroupMembers = true;
                                    checkFetchComplete();
                                } else {
                                    mHasFetchedGroupMembers = true;
                                    checkFetchComplete();
                                }
                            }, this::fetchGroupMembersError));
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:26,代碼來源:DBManager.java

示例5: getGroups

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
public void getGroups(String groupId) {
    if (!mHasFetchedGroups) {
        fetchGroups();
    } else {
        ApiRetrofit.getInstance().getGroupInfo(groupId)
                .subscribeOn(Schedulers.io())
                .observeOn(Schedulers.io())
                .subscribe(getGroupInfoResponse -> {
                    if (getGroupInfoResponse != null && getGroupInfoResponse.getCode() == 200) {
                        GetGroupInfoResponse.ResultEntity groupInfo = getGroupInfoResponse.getResult();
                        if (groupInfo != null) {
                            String role = groupInfo.getCreatorId().equalsIgnoreCase(UserCache.getId()) ? "0" : "1";
                            saveOrUpdateGroup(new Groups(groupId, groupInfo.getName(), groupInfo.getPortraitUri(), role));
                        }
                    }
                }, this::loadError);
    }
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:19,代碼來源:DBManager.java

示例6: getGroupMember

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
public void getGroupMember(String groupId) {
    if (!mHasFetchedGroupMembers) {
        deleteGroupMembers();
        mGroupsList = getGroups();
        fetchGroupMembers();
    } else {
        ApiRetrofit.getInstance().getGroupMember(groupId)
                .subscribeOn(Schedulers.io())
                .observeOn(Schedulers.io())
                .subscribe(getGroupMemberResponse -> {
                    if (getGroupMemberResponse != null && getGroupMemberResponse.getCode() == 200) {
                        List<GetGroupMemberResponse.ResultEntity> list = getGroupMemberResponse.getResult();
                        if (list != null && list.size() > 0) {
                            deleteGroupMembersByGroupId(groupId);
                            saveGroupMembers(list, groupId);
                            BroadcastManager.getInstance(UIUtils.getContext()).sendBroadcast(AppConst.UPDATE_GROUP_MEMBER, groupId);
                            BroadcastManager.getInstance(UIUtils.getContext()).sendBroadcast(AppConst.UPDATE_CONVERSATIONS);
                        }
                    }
                }, this::loadError);
    }

}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:24,代碼來源:DBManager.java

示例7: addFriend

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
public void addFriend(String userId) {
    String msg = getView().getEtMsg().getText().toString().trim();
    ApiRetrofit.getInstance().sendFriendInvitation(userId, msg)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(friendInvitationResponse -> {
                if (friendInvitationResponse.getCode() == 200) {
                    UIUtils.showToast(UIUtils.getString(R.string.rquest_sent_success));
                    mContext.finish();
                } else {
                    UIUtils.showToast(UIUtils.getString(R.string.rquest_sent_fail));
                }
            }, this::loadError);
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:15,代碼來源:PostScriptAtPresenter.java

示例8: loadData

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
private void loadData() {
    ApiRetrofit.getInstance().getAllUserRelationship()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(userRelationshipResponse -> {
                if (userRelationshipResponse.getCode() == 200) {
                    List<UserRelationshipResponse.ResultEntity> result = userRelationshipResponse.getResult();

                    if (result != null && result.size() > 0) {
                        for (int i = 0; i < result.size(); i++) {
                            UserRelationshipResponse.ResultEntity re = result.get(i);
                            if (re.getStatus() == 10) {//是我發起的添加好友請求
                                result.remove(re);
                                i--;
                            }
                        }
                    }

                    if (result != null && result.size() > 0) {
                        getView().getLlHasNewFriend().setVisibility(View.VISIBLE);
                        mData.clear();
                        mData.addAll(result);
                        if (mAdapter != null)
                            mAdapter.notifyDataSetChangedWrapper();
                    } else {
                        getView().getLlNoNewFriend().setVisibility(View.VISIBLE);
                    }
                } else {
                    Observable.error(new ServerException(UIUtils.getString(R.string.load_error)));
                }
            }, this::loadError);
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:33,代碼來源:NewFriendAtPresenter.java

示例9: agreeFriends

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的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

示例10: addGroupMember

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
public void addGroupMember(ArrayList<String> selectedIds) {
    LogUtils.sf("addGroupMember : " + selectedIds);
    mContext.showWaitingDialog(UIUtils.getString(R.string.please_wait));
    ApiRetrofit.getInstance().addGroupMember(mSessionId, selectedIds)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(addGroupMemberResponse -> {
                if (addGroupMemberResponse != null && addGroupMemberResponse.getCode() == 200) {
                    LogUtils.sf("網絡請求成功,開始添加群成員:");
                    Groups groups = DBManager.getInstance().getGroupsById(mSessionId);
                    for (String groupMemberId : selectedIds) {
                        UserInfo userInfo = DBManager.getInstance().getUserInfo(groupMemberId);
                        if (userInfo != null) {
                            GroupMember newMember = new GroupMember(mSessionId,
                                    userInfo.getUserId(),
                                    userInfo.getName(),
                                    userInfo.getPortraitUri().toString(),
                                    userInfo.getName(),
                                    PinyinUtils.getPinyin(userInfo.getName()),
                                    PinyinUtils.getPinyin(userInfo.getName()),
                                    groups.getName(),
                                    PinyinUtils.getPinyin(groups.getName()),
                                    groups.getPortraitUri());
                            DBManager.getInstance().saveOrUpdateGroupMember(newMember);
                            LogUtils.sf("添加群成員成功");
                        }
                    }
                    LogUtils.sf("添加群成員結束");
                    mContext.hideWaitingDialog();
                    loadData();
                    LogUtils.sf("重新加載數據");
                    UIUtils.showToast(UIUtils.getString(R.string.add_member_success));
                }
            }, this::addMembersError);
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:36,代碼來源:SessionInfoAtPresenter.java

示例11: deleteGroupMembers

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
public void deleteGroupMembers(ArrayList<String> selectedIds) {
    mContext.showWaitingDialog(UIUtils.getString(R.string.please_wait));
    ApiRetrofit.getInstance().deleGroupMember(mSessionId, selectedIds)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(deleteGroupMemberResponse -> {
                if (deleteGroupMemberResponse != null && deleteGroupMemberResponse.getCode() == 200) {
                    LogUtils.sf("網絡請求成功,開始刪除:");
                    for (int i = 0; i < mData.size(); i++) {
                        GroupMember member = mData.get(i);
                        if (selectedIds.contains(member.getUserId())) {
                            LogUtils.sf("刪除用戶:" + member.getUserId());
                            member.delete();
                            mData.remove(i);
                            i--;
                        }
                    }
                    LogUtils.sf("刪除結束");
                    mContext.hideWaitingDialog();
                    setAdapter();
                    UIUtils.showToast(UIUtils.getString(R.string.del_member_success));
                } else {
                    LogUtils.sf("網絡請求失敗");
                    mContext.hideWaitingDialog();
                    UIUtils.showToast(UIUtils.getString(R.string.del_member_fail));
                }
            }, this::delMembersError);
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:29,代碼來源:SessionInfoAtPresenter.java

示例12: setDisplayName

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
public void setDisplayName() {
    View view = View.inflate(mContext, R.layout.dialog_group_display_name_change, null);
    mSetDisplayNameDialog = new CustomDialog(mContext, view, R.style.MyDialog);
    EditText etName = (EditText) view.findViewById(R.id.etName);
    etName.setText(mDisplayName);
    etName.setSelection(mDisplayName.length());
    view.findViewById(R.id.tvCancle).setOnClickListener(v -> mSetDisplayNameDialog.dismiss());
    view.findViewById(R.id.tvOk).setOnClickListener(v -> {
        String displayName = etName.getText().toString().trim();
        if (!TextUtils.isEmpty(displayName)) {
            ApiRetrofit.getInstance().setGroupDisplayName(mSessionId, displayName)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(setGroupDisplayNameResponse -> {
                        if (setGroupDisplayNameResponse != null && setGroupDisplayNameResponse.getCode() == 200) {
                            Groups groups = DBManager.getInstance().getGroupsById(mSessionId);
                            if (groups != null) {
                                groups.setDisplayName(displayName);
                                groups.saveOrUpdate("groupid=?", groups.getGroupId());
                                mDisplayName = displayName;
                                getView().getOivNickNameInGroup().setRightText(mDisplayName);
                            }
                            UIUtils.showToast(UIUtils.getString(R.string.change_success));
                        } else {
                            UIUtils.showToast(UIUtils.getString(R.string.change_fail));
                        }
                        mSetDisplayNameDialog.dismiss();
                    }, this::setDisplayNameError);
        }
    });
    mSetDisplayNameDialog.show();
}
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:33,代碼來源:SessionInfoAtPresenter.java

示例13: login

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
public void login() {
    String phone = getView().getEtPhone().getText().toString().trim();
    String pwd = getView().getEtPwd().getText().toString().trim();

    if (TextUtils.isEmpty(phone)) {
        UIUtils.showToast(UIUtils.getString(R.string.phone_not_empty));
        return;
    }
    if (TextUtils.isEmpty(pwd)) {
        UIUtils.showToast(UIUtils.getString(R.string.password_not_empty));
        return;
    }

    mContext.showWaitingDialog(UIUtils.getString(R.string.please_wait));
    ApiRetrofit.getInstance().login(AppConst.REGION, phone, pwd)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(loginResponse -> {
                int code = loginResponse.getCode();
                mContext.hideWaitingDialog();
                if (code == 200) {
                    UserCache.save(loginResponse.getResult().getId(), phone, loginResponse.getResult().getToken());
                    mContext.jumpToActivityAndClearTask(MainActivity.class);
                    mContext.finish();
                } else {
                    loginError(new ServerException(UIUtils.getString(R.string.login_error) + code));
                }
            }, this::loginError);
}
 
開發者ID:GitLqr,項目名稱:LQRWeChat,代碼行數:30,代碼來源:LoginAtPresenter.java

示例14: login

import com.lqr.wechat.api.ApiRetrofit; //導入依賴的package包/類
public void login() {
    String phone = getView().getEtPhone().getText().toString().trim();
    String pwd = getView().getEtPwd().getText().toString().trim();

    if (TextUtils.isEmpty(phone)) {
        UIUtils.showToast(UIUtils.getString(R.string.phone_not_empty));
        return;
    }
    if (TextUtils.isEmpty(pwd)) {
        UIUtils.showToast(UIUtils.getString(R.string.password_not_empty));
        return;
    }

    mContext.showWaitingDialog(UIUtils.getString(R.string.please_wait));
    /**
     * 通過自己寫的Retrofit封裝類對象調用登錄方法傳入參數 執行請求返回jsonBean對象
     */
    ApiRetrofit.getInstance().login(AppConst.REGION, phone, pwd)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(loginResponse -> {
                int code = loginResponse.getCode();
                mContext.hideWaitingDialog();
                if (code == 200) {
                    /**
                     * 緩存Token ,Phone,token
                     */
                    UserCache.save(loginResponse.getResult().getId(), phone, loginResponse.getResult().getToken());
                    mContext.jumpToActivityAndClearTask(MainActivity.class);
                    mContext.finish();
                } else {
                    loginError(new ServerException(UIUtils.getString(R.string.login_error) + code));//有錯誤拋出錯誤
                }
            }, this::loginError);
}
 
開發者ID:lo625090140,項目名稱:lqrwechatrongcloud,代碼行數:36,代碼來源:LoginAtPresenter.java


注:本文中的com.lqr.wechat.api.ApiRetrofit類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。