本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}