v2x-dns
This commit is contained in:
@@ -94,4 +94,14 @@ public class V2XApiServiceFactory {
|
||||
}
|
||||
return mDataServiceApiService;
|
||||
}
|
||||
public static V2XApiService getStrategyPushApiService(Context context) {
|
||||
if (mDataServiceApiService == null) {
|
||||
synchronized (V2XApiServiceFactory.class) {
|
||||
if (mDataServiceApiService == null) {
|
||||
mDataServiceApiService = getApiService(context, HostConst.STRATEGY_PUSH_HOST);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mDataServiceApiService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,74 +66,70 @@ public class V2XRefreshModel {
|
||||
|
||||
private void init(Context context) {
|
||||
this.mContext = context;
|
||||
IMogoNetwork network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(context);
|
||||
this.mV2XApiService = network.create(V2XApiService.class, HttpConstant.Companion.getNetHost());
|
||||
// IMogoNetwork network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(context);
|
||||
// this.mV2XApiService = network.create(V2XApiService.class, HttpConstant.Companion.getNetHost());
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新地图点数据,同步获取
|
||||
*/
|
||||
public void querySnapshotAsync(MogoLatLng latLng, int radius, int limit) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
final RefreshBody refreshBody = new RefreshBody();
|
||||
refreshBody.limit = limit;
|
||||
refreshBody.location = new RefreshBody.LatLon(latLng.lat, latLng.lon);
|
||||
refreshBody.radius = radius;
|
||||
refreshBody.dataType.add(ServiceConst.CARD_TYPE_ROAD_CONDITION);
|
||||
refreshBody.viewPush = true;
|
||||
query.put("data", GsonUtil.jsonFromObject(refreshBody));
|
||||
mV2XApiService.querySnapshotAsync(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
final RefreshBody refreshBody = new RefreshBody();
|
||||
refreshBody.limit = limit;
|
||||
refreshBody.location = new RefreshBody.LatLon(latLng.lat, latLng.lon);
|
||||
refreshBody.radius = radius;
|
||||
refreshBody.dataType.add(ServiceConst.CARD_TYPE_ROAD_CONDITION);
|
||||
refreshBody.viewPush = true;
|
||||
query.put("data", GsonUtil.jsonFromObject(refreshBody));
|
||||
V2XApiServiceFactory.getLauncherSnapshotApiService(mContext).querySnapshotAsync(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新地图点数据,同步获取
|
||||
*/
|
||||
public void querySnapshotSync(MogoLatLng latLng, int radius, int limit, final V2XRefreshCallback<MarkerResponse> callback) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
final RefreshBody refreshBody = new RefreshBody();
|
||||
refreshBody.limit = limit;
|
||||
refreshBody.location = new RefreshBody.LatLon(latLng.lat, latLng.lon);
|
||||
refreshBody.radius = radius;
|
||||
refreshBody.dataType.add(ServiceConst.CARD_TYPE_ROAD_CONDITION);
|
||||
refreshBody.viewPush = true;
|
||||
query.put("data", GsonUtil.jsonFromObject(refreshBody));
|
||||
mV2XApiService.querySnapshotSync(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<MarkerResponse>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(MarkerResponse o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
final RefreshBody refreshBody = new RefreshBody();
|
||||
refreshBody.limit = limit;
|
||||
refreshBody.location = new RefreshBody.LatLon(latLng.lat, latLng.lon);
|
||||
refreshBody.radius = radius;
|
||||
refreshBody.dataType.add(ServiceConst.CARD_TYPE_ROAD_CONDITION);
|
||||
refreshBody.viewPush = true;
|
||||
query.put("data", GsonUtil.jsonFromObject(refreshBody));
|
||||
V2XApiServiceFactory.getLauncherSnapshotApiService(mContext).querySnapshotSync(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<MarkerResponse>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(MarkerResponse o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
callback.onFail(message);
|
||||
}
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,34 +140,32 @@ public class V2XRefreshModel {
|
||||
* @param callback 回调
|
||||
*/
|
||||
public void refreshHeartBeat(String sn, String videoChannel, final V2XRefreshCallback callback) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> liveBroadcast = new ParamsProvider.Builder(mContext).build();
|
||||
liveBroadcast.put("sn", sn);
|
||||
liveBroadcast.put("data", GsonUtil.getGson().toJson(new V2XLiveCarBroadcastReq(sn, videoChannel)));
|
||||
mV2XApiService.refreshHeartBeat(liveBroadcast)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> liveBroadcast = new ParamsProvider.Builder(mContext).build();
|
||||
liveBroadcast.put("sn", sn);
|
||||
liveBroadcast.put("data", GsonUtil.getGson().toJson(new V2XLiveCarBroadcastReq(sn, videoChannel)));
|
||||
V2XApiServiceFactory.getDataApiService(mContext).refreshHeartBeat(liveBroadcast)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -181,34 +175,32 @@ public class V2XRefreshModel {
|
||||
* @param callback 回调
|
||||
*/
|
||||
public void giveLikeLiveVideo(final V2XRefreshCallback callback, String snStr) {
|
||||
if (mV2XApiService != null) {
|
||||
Logger.d(V2XConst.MODULE_NAME, "点赞车机:" + snStr);
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
query.put("data", "{\"sn\":" + snStr + "}");
|
||||
mV2XApiService.giveLikeLiveVideo(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
Logger.d(V2XConst.MODULE_NAME, "点赞车机:" + snStr);
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
query.put("data", "{\"sn\":" + snStr + "}");
|
||||
V2XApiServiceFactory.getGeoFenceCarServiceApiService(mContext).giveLikeLiveVideo(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,35 +209,33 @@ public class V2XRefreshModel {
|
||||
* @param sn 目标车机SN
|
||||
*/
|
||||
public void queryUserInfoBySn(String sn, final V2XRefreshCallback<V2XUserInfoRes> callback) {
|
||||
if (mV2XApiService != null) {
|
||||
RequestBody body = RequestBody.create(
|
||||
okhttp3.MediaType.parse("application/json; charset=utf-8"),
|
||||
"{\"sn\":\"" + sn + "\"}");
|
||||
RequestBody body = RequestBody.create(
|
||||
okhttp3.MediaType.parse("application/json; charset=utf-8"),
|
||||
"{\"sn\":\"" + sn + "\"}");
|
||||
|
||||
mV2XApiService.queryUserInfoBySn(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XUserInfoRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XUserInfoRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
V2XApiServiceFactory.getRealtimeLocationApiService(mContext).queryUserInfoBySn(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XUserInfoRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XUserInfoRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,49 +245,47 @@ public class V2XRefreshModel {
|
||||
*/
|
||||
public void queryNearbyVehicleLiveByLocation(
|
||||
V2XRefreshCallback<V2XLiveCarRes> callback, double lon, double lat) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
|
||||
StringBuffer dataStr = new StringBuffer();
|
||||
dataStr.append("{");
|
||||
dataStr.append("\"lon\":");
|
||||
dataStr.append(lon);
|
||||
dataStr.append(",");
|
||||
dataStr.append("\"lat\":");
|
||||
dataStr.append(lat);
|
||||
dataStr.append(",");
|
||||
dataStr.append("\"radius\":");
|
||||
dataStr.append(0.5);
|
||||
dataStr.append(",");
|
||||
dataStr.append("\"size\":");
|
||||
dataStr.append(5);
|
||||
dataStr.append("}");
|
||||
StringBuffer dataStr = new StringBuffer();
|
||||
dataStr.append("{");
|
||||
dataStr.append("\"lon\":");
|
||||
dataStr.append(lon);
|
||||
dataStr.append(",");
|
||||
dataStr.append("\"lat\":");
|
||||
dataStr.append(lat);
|
||||
dataStr.append(",");
|
||||
dataStr.append("\"radius\":");
|
||||
dataStr.append(0.5);
|
||||
dataStr.append(",");
|
||||
dataStr.append("\"size\":");
|
||||
dataStr.append(5);
|
||||
dataStr.append("}");
|
||||
|
||||
query.put("data", dataStr.toString());
|
||||
mV2XApiService.queryNearbyVehicleLiveByLocation(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XLiveCarRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XLiveCarRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
query.put("data", dataStr.toString());
|
||||
V2XApiServiceFactory.getRealtimeLocationApiService(mContext).queryNearbyVehicleLiveByLocation(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XLiveCarRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XLiveCarRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,38 +294,36 @@ public class V2XRefreshModel {
|
||||
* @param callback 回调
|
||||
*/
|
||||
public void livePush(V2XRefreshCallback<V2XLivePushVoRes> callback, String sn, int playType) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
query.put("data", "{" +
|
||||
"\"eventId\": \"yycp\"," +
|
||||
"\"sn\": \"" + sn + "\"," +
|
||||
"\"type\": \"" + playType + "\"," +
|
||||
"\"videoChannel\": \"C_1\"" +
|
||||
"}");
|
||||
mV2XApiService.livePush(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XLivePushVoRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XLivePushVoRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> query = new ParamsProvider.Builder(mContext).build();
|
||||
query.put("data", "{" +
|
||||
"\"eventId\": \"yycp\"," +
|
||||
"\"sn\": \"" + sn + "\"," +
|
||||
"\"type\": \"" + playType + "\"," +
|
||||
"\"videoChannel\": \"C_1\"" +
|
||||
"}");
|
||||
V2XApiServiceFactory.getDataApiService(mContext).livePush(query)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XLivePushVoRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XLivePushVoRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,40 +332,37 @@ public class V2XRefreshModel {
|
||||
* @param callback
|
||||
*/
|
||||
public void cancelHelpSignal(V2XRefreshCallback<BaseData> callback) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = new StringBuilder()
|
||||
.append("{")
|
||||
.append("\"sn\":").append(Utils.getSn())
|
||||
.append(",")
|
||||
.append("\"vehicleType\":")
|
||||
.append(0)
|
||||
.append("}").toString();
|
||||
map.put("data", json);
|
||||
mV2XApiService.sendHelpSignal(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = new StringBuilder()
|
||||
.append("{")
|
||||
.append("\"sn\":").append(Utils.getSn())
|
||||
.append(",")
|
||||
.append("\"vehicleType\":")
|
||||
.append(0)
|
||||
.append("}").toString();
|
||||
map.put("data", json);
|
||||
V2XApiServiceFactory.getRealtimeLocationApiService(mContext).sendHelpSignal(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,33 +371,30 @@ public class V2XRefreshModel {
|
||||
* @param callback
|
||||
*/
|
||||
public void getHelpSignal(V2XRefreshCallback<V2XSeekHelpRes> callback) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
map.put("sn", Utils.getSn());
|
||||
mV2XApiService.queryHelpSignal(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XSeekHelpRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XSeekHelpRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
map.put("sn", Utils.getSn());
|
||||
V2XApiServiceFactory.getRealtimeLocationApiService(mContext).queryHelpSignal(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XSeekHelpRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XSeekHelpRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -423,94 +403,88 @@ public class V2XRefreshModel {
|
||||
* @param callback
|
||||
*/
|
||||
public void getMockUserInfos(V2XRefreshCallback<V2XDemoUserInfoRes> callback) {
|
||||
if (mV2XApiService != null) {
|
||||
mV2XApiService.getMockUserInfos().subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XDemoUserInfoRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XDemoUserInfoRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
V2XApiServiceFactory.getLauncherSnapshotApiService(mContext).getMockUserInfos().subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XDemoUserInfoRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XDemoUserInfoRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称获取策略详情
|
||||
*/
|
||||
public void getStrategyPush(V2XRefreshCallback<V2XStrategyPushRes> callback) {
|
||||
if (mV2XApiService != null) {
|
||||
mV2XApiService.getStrategyPush().subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XStrategyPushRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XStrategyPushRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
V2XApiServiceFactory.getStrategyPushApiService(mContext).getStrategyPush().subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XStrategyPushRes>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XStrategyPushRes o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 违章地段查询接口
|
||||
*/
|
||||
public void queryIllegalPark(V2XRefreshCallback<MarkerResponse> callback, double lon, double lat) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = "{\"location\":{\"lat\":" + lat + ",\"lon\":" + lon + "},\"radius\":50}";
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = "{\"location\":{\"lat\":" + lat + ",\"lon\":" + lon + "},\"radius\":50}";
|
||||
// String json = "{\"location\":{\"lat\":39.968139,\"lon\":116.380476},\"radius\":1000}";
|
||||
map.put("data", json);
|
||||
mV2XApiService.queryIllegalPark(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<MarkerResponse>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(MarkerResponse o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
map.put("data", json);
|
||||
V2XApiServiceFactory.getLauncherSnapshotApiService(mContext).queryIllegalPark(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<MarkerResponse>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(MarkerResponse o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,42 +494,40 @@ public class V2XRefreshModel {
|
||||
String infoId,
|
||||
String poiType,
|
||||
int likeOrDislike) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = new StringBuilder()
|
||||
.append("{")
|
||||
.append("\"infoId\":").append(infoId)
|
||||
.append(",")
|
||||
.append("\"poiType\":").append(poiType)
|
||||
.append(",")
|
||||
.append("\"likeOrdislike\":").append(likeOrDislike)
|
||||
.append(",")
|
||||
.append("\"sn\":").append(Utils.getSn())
|
||||
.append("}").toString();
|
||||
map.put("data", json);
|
||||
mV2XApiService.addPoiInfoFabulous(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = new StringBuilder()
|
||||
.append("{")
|
||||
.append("\"infoId\":").append(infoId)
|
||||
.append(",")
|
||||
.append("\"poiType\":").append(poiType)
|
||||
.append(",")
|
||||
.append("\"likeOrdislike\":").append(likeOrDislike)
|
||||
.append(",")
|
||||
.append("\"sn\":").append(Utils.getSn())
|
||||
.append("}").toString();
|
||||
map.put("data", json);
|
||||
V2XApiServiceFactory.getDevaApiService(mContext).addPoiInfoFabulous(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -564,29 +536,27 @@ public class V2XRefreshModel {
|
||||
* "enthusiasticSn":"testSn02",响应求助SN
|
||||
*/
|
||||
public void respondingToHelp(String seekHelpSn) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = new StringBuilder()
|
||||
.append("{")
|
||||
.append("\"seekHelpSn\":").append(seekHelpSn)
|
||||
.append(",")
|
||||
.append("\"enthusiasticSn\":").append(Utils.getSn())
|
||||
.append("}").toString();
|
||||
map.put("data", json);
|
||||
mV2XApiService.respondingToHelp(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = new StringBuilder()
|
||||
.append("{")
|
||||
.append("\"seekHelpSn\":").append(seekHelpSn)
|
||||
.append(",")
|
||||
.append("\"enthusiasticSn\":").append(Utils.getSn())
|
||||
.append("}").toString();
|
||||
map.put("data", json);
|
||||
V2XApiServiceFactory.getDevaApiService(mContext).respondingToHelp(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -598,61 +568,57 @@ public class V2XRefreshModel {
|
||||
public void manualMarkingTrafficJam(String id,
|
||||
int status,
|
||||
String helpId) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = "{" + "\"id\":\"" + id + "\"," + "\"sn\":\"" + Utils.getSn() + "\"," + "\"status\":" + status + "," + "\"helpId\":\"" + helpId + "\"}";
|
||||
map.put("data", json);
|
||||
mV2XApiService.manualMarkingTrafficJam(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
String json = "{" + "\"id\":\"" + id + "\"," + "\"sn\":\"" + Utils.getSn() + "\"," + "\"status\":" + status + "," + "\"helpId\":\"" + helpId + "\"}";
|
||||
map.put("data", json);
|
||||
V2XApiServiceFactory.getDevaApiService(mContext).manualMarkingTrafficJam(map).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void queryCrossRoadsLive(V2XRefreshCallback<V2XLiveCrossRoad> callback) {
|
||||
if (mV2XApiService != null) {
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
MogoLocation lastKnowLocation = V2XServiceManager.getMapService().getSingletonLocationClient(AbsMogoApplication.getApp()).getLastKnowLocation();
|
||||
double lat = lastKnowLocation.getLatitude();
|
||||
double lon = lastKnowLocation.getLongitude();
|
||||
String tmpLat = String.valueOf(lat);
|
||||
String tmpLon = String.valueOf(lon);
|
||||
float bearing = lastKnowLocation.getBearing();
|
||||
String json = "{\"lat\":" + tmpLat + ",\"lon\":" + tmpLon + ",\"direction\":" + bearing + "}";
|
||||
map.put("sn", Utils.getSn());
|
||||
map.put("data", json);
|
||||
mV2XApiService.queryCrossRoadsLive(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XLiveCrossRoad>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XLiveCrossRoad o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
final Map<String, Object> map = new ParamsProvider.Builder(mContext).build();
|
||||
MogoLocation lastKnowLocation = V2XServiceManager.getMapService().getSingletonLocationClient(AbsMogoApplication.getApp()).getLastKnowLocation();
|
||||
double lat = lastKnowLocation.getLatitude();
|
||||
double lon = lastKnowLocation.getLongitude();
|
||||
String tmpLat = String.valueOf(lat);
|
||||
String tmpLon = String.valueOf(lon);
|
||||
float bearing = lastKnowLocation.getBearing();
|
||||
String json = "{\"lat\":" + tmpLat + ",\"lon\":" + tmpLon + ",\"direction\":" + bearing + "}";
|
||||
map.put("sn", Utils.getSn());
|
||||
map.put("data", json);
|
||||
V2XApiServiceFactory.getGeoFenceCarServiceApiService(mContext).queryCrossRoadsLive(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<V2XLiveCrossRoad>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(V2XLiveCrossRoad o) {
|
||||
super.onSuccess(o);
|
||||
if (callback != null) {
|
||||
callback.onSuccess(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
message = "网络错误,请稍后重试";
|
||||
}
|
||||
callback.onFail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user