Commit 8f17ac99 by sikang

update gateway

parent 8a6eb5ad
......@@ -292,8 +292,11 @@ public interface UserApi {
@GET("record/employ-photo")
Observable<RecordFilesResponse> getJobImg();
@GET
Observable<ResponseBody> analytics(@Url String url);
@FormUrlEncoded
@POST("google/analytics/index")
Observable<ResponseBody> analytics(@Field("name") String name,
@Field("imei") String imei,
@Field("type") String type);
@GET("record/bankcard")
Observable<UserBankInfo> getBankCardInfo();
......@@ -355,6 +358,4 @@ public interface UserApi {
@Query("passbackparams") String passbackparams);
}
......@@ -93,58 +93,61 @@ public class UserPresenter extends BasePresenter<UserApi> {
public void getGateway(String action, List<String> gatewayUrl) {
Log.d("Android", AppInfoUtils.getAndroidID(LibConfig.getContext()));
FbDeepLink.fetchDeepLink();
Observable.fromIterable(gatewayUrl)
.subscribeOn(Schedulers.io())
.concatMap(new Function<String, ObservableSource<GatewayInfoBean>>() {
@Override
public ObservableSource<GatewayInfoBean> apply(String s) throws Exception {
if (gatewayUrl.indexOf(s) == gatewayUrl.size() - 1) {
return getApiService().getGateway(s);
}
return getApiService().getGateway(s).onErrorReturn(new Function<Throwable, GatewayInfoBean>() {
@Override
public GatewayInfoBean apply(Throwable throwable) throws Exception {
return new GatewayInfoBean();
}
});
}
})
.filter(new Predicate<GatewayInfoBean>() {
@Override
public boolean test(GatewayInfoBean gatewayInfoBean) throws Exception {
return gatewayInfoBean != null && gatewayInfoBean.gateway != null;
}
})
.take(1)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new HttpObserver<GatewayInfoBean>(action) {
@Override
public void onStart() {
if (view != null) {
view.onHttpStart(action, false);
}
}
@Override
public void onSuccess(GatewayInfoBean gatewayInfoBean) {
Gateway.setGatewayInfoBean(gatewayInfoBean);
submitDeviceInfo();
getCustomerMsg(action);
}
@Override
public void onError(int code, String msg) {
if (view != null) {
view.onHttpError(action, msg);
}
}
@Override
public void onFinish() {
}
});
// Observable.fromIterable(gatewayUrl)
// .subscribeOn(Schedulers.io())
// .concatMap(new Function<String, ObservableSource<GatewayInfoBean>>() {
// @Override
// public ObservableSource<GatewayInfoBean> apply(String s) throws Exception {
// if (gatewayUrl.indexOf(s) == gatewayUrl.size() - 1) {
// return getApiService().getGateway(s);
// }
// return getApiService().getGateway(s).onErrorReturn(new Function<Throwable, GatewayInfoBean>() {
// @Override
// public GatewayInfoBean apply(Throwable throwable) throws Exception {
// return new GatewayInfoBean();
// }
// });
// }
// })
// .filter(new Predicate<GatewayInfoBean>() {
// @Override
// public boolean test(GatewayInfoBean gatewayInfoBean) throws Exception {
// return gatewayInfoBean != null && gatewayInfoBean.gateway != null;
// }
// })
// .take(1)
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new HttpObserver<GatewayInfoBean>(action) {
// @Override
// public void onStart() {
// if (view != null) {
// view.onHttpStart(action, false);
// }
// }
//
// @Override
// public void onSuccess(GatewayInfoBean gatewayInfoBean) {
// Gateway.setGatewayInfoBean(gatewayInfoBean);
//
// submitDeviceInfo();
//
// getCustomerMsg(action);
// }
//
// @Override
// public void onError(int code, String msg) {
// if (view != null) {
// view.onHttpError(action, msg);
// }
// }
//
// @Override
// public void onFinish() {
// }
// });
}
......@@ -918,15 +921,10 @@ public class UserPresenter extends BasePresenter<UserApi> {
@SuppressLint("CheckResult")
public void analytics(String action, boolean isWifi) {
StringBuilder builder = new StringBuilder();
builder.append("http://13.250.10.209:8878/google/analytics/");
builder.append(LibConfig.APPLICATION_ID);
builder.append("/");
builder.append(AppInfoUtils.getAndroidID(LibConfig.getContext()));
builder.append("/");
builder.append(isWifi ? "2" : "1");
UserApi userApi = ServiceGenerator.getService(UserApi.class, "http://13.250.10.209:8878");
String type = isWifi ? "2" : "1";
handleRequest(getApiService().analytics(builder.toString()), new HttpObserver<ResponseBody>() {
handleRequest(userApi.analytics(LibConfig.APPLICATION_ID, AppInfoUtils.getAndroidID(LibConfig.getContext()), type), new HttpObserver<ResponseBody>() {
@Override
public void onStart() {
}
......@@ -934,7 +932,8 @@ public class UserPresenter extends BasePresenter<UserApi> {
@Override
public void onSuccess(ResponseBody data) {
try {
if (data.string().equals("ok") && !isWifi) {
String result = data.string();
if (result.equals("ok") && !isWifi) {
view.onHttpSuccess(action, "ok");
}
} catch (IOException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment