修改了V2X请求获取周边事件的方式为http同步返回结果的方式
This commit is contained in:
@@ -5,7 +5,9 @@ import android.os.Handler;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.v2x.listener.V2XLocationListener;
|
||||
import com.mogo.module.v2x.network.V2XRefreshCallback;
|
||||
import com.mogo.module.v2x.network.V2XRefreshModel;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -18,7 +20,7 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
* desc :
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XMarkerService {
|
||||
public class V2XMarkerService implements V2XRefreshCallback<MarkerResponse> {
|
||||
private final String TAG = "V2XMarkerService";
|
||||
|
||||
// 一分钟获取一次最新的路况信息
|
||||
@@ -48,12 +50,13 @@ public class V2XMarkerService {
|
||||
public void refreshMarkerData(MogoLocation location) {
|
||||
try {
|
||||
if (mV2XRefreshModel != null && location != null) {
|
||||
//Logger.d(MODULE_NAME, "V2X道路事件:执行气泡刷新操作。");
|
||||
Logger.d(MODULE_NAME, "V2X道路事件:执行气泡刷新操作。");
|
||||
// 获取目前最新的周边的poi点
|
||||
mV2XRefreshModel.querySnapshotAsync(
|
||||
mV2XRefreshModel.querySnapshotSync(
|
||||
new MogoLatLng(location.getLatitude(), location.getLongitude()),
|
||||
(int) getMapCameraFactWidth(),
|
||||
999);
|
||||
999,
|
||||
this);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -105,4 +108,16 @@ public class V2XMarkerService {
|
||||
}
|
||||
refreshHandler.post(refreshRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(MarkerResponse result) {
|
||||
if (V2XSocketManager.getInstance().getV2XMessageListener_401011() != null) {
|
||||
V2XSocketManager.getInstance().getV2XMessageListener_401011().onMsgReceived(result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String msg) {
|
||||
Logger.e(TAG, "刷新V2X道路事件异常请检查参数");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,10 @@ public class V2XSocketManager {
|
||||
);
|
||||
}
|
||||
|
||||
public V2XMessageListener_401011 getV2XMessageListener_401011() {
|
||||
return v2XMessageListener_401011;
|
||||
}
|
||||
|
||||
/**
|
||||
* 道路事件,服务端下发
|
||||
*/
|
||||
|
||||
@@ -39,12 +39,19 @@ public interface V2XApiService {
|
||||
Observable<BaseData> refreshHeartBeat(@FieldMap Map<String, Object> liveBroadcast);
|
||||
|
||||
/**
|
||||
* 刷新地图气泡点
|
||||
* 刷新地图气泡点,异步获取
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/yycp-launcherSnapshot/launcherSnapshot/querySnapshotAsync")
|
||||
Observable<BaseData> querySnapshotAsync(@FieldMap Map<String, Object> parameters);
|
||||
|
||||
/**
|
||||
* 刷新地图气泡点,同步获取
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/yycp-launcherSnapshot/launcherSnapshot/querySnapshotSync")
|
||||
Observable<MarkerResponse> querySnapshotSync(@FieldMap Map<String, Object> parameters);
|
||||
|
||||
/**
|
||||
* 直播点赞
|
||||
*/
|
||||
|
||||
@@ -67,7 +67,7 @@ public class V2XRefreshModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新地图点数据
|
||||
* 刷新地图点数据,同步获取
|
||||
*/
|
||||
public void querySnapshotAsync(MogoLatLng latLng, int radius, int limit) {
|
||||
if (mV2XApiService != null) {
|
||||
@@ -96,6 +96,42 @@ public class V2XRefreshModel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新地图点数据,同步获取
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
if (callback != null) {
|
||||
callback.onFail(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发刷新直播心跳
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user