Commit 8f17ac99 by sikang

update gateway

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