57 lines
1.9 KiB
Java
57 lines
1.9 KiB
Java
package com.shayu.onetoone.manager;
|
|
|
|
import android.content.Context;
|
|
|
|
import com.yunbao.common.bean.GiftNamingInfoModel;
|
|
import com.yunbao.common.http.API;
|
|
import com.yunbao.common.http.ResponseModel;
|
|
import com.yunbao.common.http.base.HttpCallback;
|
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
import io.reactivex.functions.Consumer;
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
|
/**
|
|
* 网络管理类 使用参考{@link com.yunbao.common.http.live.LiveNetManager}
|
|
*/
|
|
public class OTONetManager {
|
|
private Context mContext;
|
|
private static OTONetManager mInstance;
|
|
|
|
private OTONetManager(Context context) {
|
|
this.mContext = context;
|
|
}
|
|
|
|
public static OTONetManager getInstance(Context context) {
|
|
if (mInstance == null) {
|
|
mInstance = new OTONetManager(context);
|
|
}
|
|
return mInstance;
|
|
}
|
|
//示例
|
|
/*
|
|
public void getGiftNamingInfo(String giftId, HttpCallback<GiftNamingInfoModel> callback) {
|
|
API.get().pdLiveApi(mContext)
|
|
.getGiftNamingInfo(giftId)
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new Consumer<ResponseModel<GiftNamingInfoModel>>() {
|
|
@Override
|
|
public void accept(ResponseModel<GiftNamingInfoModel> liveGiftBeanResponseModel) throws Exception {
|
|
if (callback!=null){
|
|
callback.onSuccess(liveGiftBeanResponseModel.getData().getInfo());
|
|
}
|
|
}
|
|
}, new Consumer<Throwable>() {
|
|
@Override
|
|
public void accept(Throwable throwable) throws Exception {
|
|
if (callback != null) {
|
|
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
|
}
|
|
}
|
|
}).isDisposed();
|
|
}
|
|
*/
|
|
|
|
}
|