This commit is contained in:
2023-10-07 14:59:21 +08:00
parent cd74b7140e
commit e7ce538d78
31 changed files with 1298 additions and 395 deletions

View File

@@ -1,11 +1,20 @@
package com.shayu.onetoone.manager;
import android.content.Context;
import android.util.Log;
import com.yunbao.common.bean.GiftNamingInfoModel;
import com.yunbao.common.http.API;
import com.shayu.onetoone.bean.JoinAnchorBean;
import com.shayu.onetoone.bean.UserBean;
import com.shayu.onetoone.network.API;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.utils.MD5Util;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
@@ -15,9 +24,13 @@ import io.reactivex.schedulers.Schedulers;
* 网络管理类 使用参考{@link com.yunbao.common.http.live.LiveNetManager}
*/
public class OTONetManager {
private static final String TAG = "网络请求";
private static final String SALT = "76576076c1f5f657b634e966c8836a06";
private static final String DEVICE = "android";
private Context mContext;
private static OTONetManager mInstance;
private OTONetManager(Context context) {
this.mContext = context;
}
@@ -28,29 +41,141 @@ public class OTONetManager {
}
return mInstance;
}
//示例
/*
public void getGiftNamingInfo(String giftId, HttpCallback<GiftNamingInfoModel> callback) {
API.get().pdLiveApi(mContext)
.getGiftNamingInfo(giftId)
/**
* 手机号登录
*/
public void login(String phoneNum, String pwd, String uuid, HttpCallback<IMLoginModel> callback) {
API.get().otoApi(mContext).loginByManager(phoneNum, pwd, uuid, "", "Android")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<GiftNamingInfoModel>>() {
.subscribe(new Consumer<ResponseModel<IMLoginModel>>() {
@Override
public void accept(ResponseModel<GiftNamingInfoModel> liveGiftBeanResponseModel) throws Exception {
if (callback!=null){
public void accept(ResponseModel<IMLoginModel> imLoginModelResponseModel) throws Exception {
if (callback != null) {
IMLoginModel model = imLoginModelResponseModel.getData().getInfo();
callback.onSuccess(model);
}
}
}, throwable -> {
Log.e(TAG, "accept: ", throwable);
if (callback != null) {
callback.onError(throwable.getMessage());
}
}).isDisposed();
}
public void getBaseInfos(boolean isLogin, HttpCallback<UserBean> callback) {
API.get().otoApi(mContext)
.getBaseInfos(isLogin ? 1 : 0)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<UserBean>>() {
@Override
public void accept(ResponseModel<UserBean> liveGiftBeanResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(liveGiftBeanResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Log.e(TAG, "accept: ", throwable);
if (callback != null) {
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
}
}
}).isDisposed();
}
*/
public void getRandJoinAnchor(HttpCallback<JoinAnchorBean> callback) {
API.get().otoApi(mContext)
.getRandJoinAnchor()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<List<JoinAnchorBean>>>() {
@Override
public void accept(ResponseModel<List<JoinAnchorBean>> model) throws Exception {
if (callback != null) {
callback.onSuccess(model.getData().getInfo().get(0));
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Log.e(TAG, "accept: ", throwable);
if (callback != null) {
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
}
}
}).isDisposed();
}
public void getCustomerService(HttpCallback<String> callback) {
API.get().otoApi(mContext)
.getCustomerService()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<List<String>>>() {
@Override
public void accept(ResponseModel<List<String>> model) throws Exception {
if (callback != null) {
callback.onSuccess(model.getData().getInfo().get(0));
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Log.e(TAG, "accept: ", throwable);
if (callback != null) {
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
}
}
}).isDisposed();
}
public void userLoginByThird(String uid,
String openId,
String promCode,
String uuid,
String nickName,
String avatar,
String type,
HttpCallback<IMLoginModel> callback) {
String sign = MD5Util.getMD5("openid=" + openId + "&" + SALT);
API.get().otoApi(mContext)
.userLoginByThird(uid,
openId,
promCode,
uuid,
nickName,
avatar,
CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "3",
DEVICE,
sign,
"Android",
type,
""
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<IMLoginModel>>() {
@Override
public void accept(ResponseModel<IMLoginModel> model) throws Exception {
if (callback != null) {
callback.onSuccess(model.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Log.e(TAG, "accept: ", throwable);
if (callback != null) {
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
}
}
}).isDisposed();
}
}