Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # gradle.properties # libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/CosStatusController.kt # modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt # modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/SimpleCoverVideoPlayer.kt
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
package com.mogo.module.share;
|
||||
|
||||
import android.content.Context;
|
||||
import android.nfc.Tag;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.amap.api.services.nearby.UploadInfoCallback;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.navi.IMogoAimlessModeListener;
|
||||
import com.mogo.map.navi.MogoCongestionInfo;
|
||||
import com.mogo.map.navi.MogoCongestionLink;
|
||||
import com.mogo.map.navi.MogoTraffic;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.RoadTrafficSegment;
|
||||
import com.mogo.module.common.entity.RoadTrafficStatus;
|
||||
import com.mogo.module.common.entity.UploadTrafficEntity;
|
||||
import com.mogo.module.share.net.TrafficModelData;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* TODO 高德巡航信息监听,并将拥堵信息上报到服务端
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_GAODE_AIMLESS_SHARE)
|
||||
public class GaoDeAimlessProvider implements IProvider {
|
||||
private final String TAG = "GaoDeAimlessProvider";
|
||||
private TrafficModelData mTanluModelData;
|
||||
List<RoadTrafficSegment> mlist = new ArrayList<>();
|
||||
RoadTrafficSegment roadTrafficSegment = new RoadTrafficSegment();
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
Log.d(TAG, "provider init……");
|
||||
if (mTanluModelData == null) {
|
||||
mTanluModelData = new TrafficModelData();
|
||||
}
|
||||
|
||||
// 开启巡航监听
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getMapServiceApi()
|
||||
.getAimless(context)
|
||||
.setAimlessModeStatus(true);
|
||||
|
||||
// 注册高德巡航回调
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getRegisterCenterApi()
|
||||
.registerMogoAimlessModeListener(TAG, new IMogoAimlessModeListener() {
|
||||
@Override
|
||||
public void onUpdateTraffic2(MogoTraffic traffic) {
|
||||
Log.d(TAG, "onUpdateTraffic2 back……");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateCongestion(MogoCongestionInfo info) {
|
||||
Log.d(TAG, GsonUtil.jsonFromObject(info));
|
||||
UploadInfo(info);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报拥堵信息
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
private void UploadInfo(MogoCongestionInfo info) {
|
||||
UploadTrafficEntity uploadTrafficEntity = new UploadTrafficEntity();
|
||||
List<RoadTrafficStatus> roadTrafficStatusList = new ArrayList<>();
|
||||
RoadTrafficStatus mStatusBean = new RoadTrafficStatus();
|
||||
mStatusBean.setLength(info.getLength());
|
||||
mStatusBean.setRoadName(info.getRoadName());
|
||||
mStatusBean.setStatus(info.getCongestionStatus());
|
||||
mStatusBean.setSegment(true);
|
||||
|
||||
if (info.getCongestionLinks() != null && info.getCongestionLinks().size() > 0) {
|
||||
mlist.clear();
|
||||
for (MogoCongestionLink data : info.getCongestionLinks()
|
||||
) {
|
||||
roadTrafficSegment.setStatus(data.getCongestionStatus());
|
||||
roadTrafficSegment.setMogoLatLngList(data.getCoords());
|
||||
mlist.add(roadTrafficSegment);
|
||||
}
|
||||
mStatusBean.setRoadTrafficSegmentList(mlist);
|
||||
}
|
||||
roadTrafficStatusList.add(mStatusBean);
|
||||
uploadTrafficEntity.setRoadTrafficStatuses(roadTrafficStatusList);
|
||||
mTanluModelData.uploadTrafficInfo(uploadTrafficEntity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.navi.IMogoAimless;
|
||||
import com.mogo.map.search.poisearch.IMogoPoiSearch;
|
||||
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
@@ -31,6 +32,7 @@ public class TanluServiceManager {
|
||||
private static IMogoIntentManager mogoIntentManager;
|
||||
private static IMogoRegisterCenter mogoRegisterCenter;
|
||||
private static IMogoTopViewManager mIMogoTopViewManager;
|
||||
private static IMogoAimless mIMogoAimless;
|
||||
|
||||
public static void init(Context context) {
|
||||
mServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
|
||||
@@ -39,6 +41,7 @@ public class TanluServiceManager {
|
||||
mAnalytics = mServiceApis.getAnalyticsApi();
|
||||
mogoIntentManager = mServiceApis.getIntentManagerApi();
|
||||
mogoRegisterCenter = mServiceApis.getRegisterCenterApi();
|
||||
mIMogoAimless = mMapService.getAimless(context);
|
||||
|
||||
mIMogoTopViewManager = mServiceApis.getTopViewManager();
|
||||
mPoiSearch = mMapService.getPoiSearch(context, new MogoPoiSearchQuery());
|
||||
@@ -81,4 +84,7 @@ public class TanluServiceManager {
|
||||
return mServiceApis;
|
||||
}
|
||||
|
||||
public static IMogoAimless getMogoAimless() {
|
||||
return mIMogoAimless;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package com.mogo.module.share
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.facade.template.IProvider
|
||||
import com.mogo.module.share.manager.TrafficUploadManager.Companion.trafficUpload
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.share.IMogoTrafficUploadProvider
|
||||
|
||||
@Route( path = MogoServicePaths.PATH_TRAFFIC_UPLOAD )
|
||||
class TrafficUploadProvider :IProvider , IMogoTrafficUploadProvider{
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
}
|
||||
|
||||
override fun verifyCurrentTrafficStatus() {
|
||||
trafficUpload.verityTrafficStatus()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,11 @@ class HttpConstant {
|
||||
const val HOST_DEMO = "http://dzt-show.zhidaohulian.com"
|
||||
const val HOST_PRODUCT = "https://dzt.zhidaohulian.com"
|
||||
|
||||
const val TMC_HOST_TEST="http://dzt-test.zhidaozhixing.com"
|
||||
const val TMC_HOST_DEMO="http://dzt-show.zhidaozhixing.com"
|
||||
const val TMC_HOST_PRODUCT="http://dzt.zhidaozhixing.com"
|
||||
|
||||
@JvmStatic
|
||||
fun getNetHost(): String {
|
||||
return when (DebugConfig.getNetMode()) {
|
||||
DebugConfig.NET_MODE_DEV -> HOST_DEV
|
||||
@@ -18,6 +23,16 @@ class HttpConstant {
|
||||
else -> HOST_PRODUCT
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getTMCHost(): String {
|
||||
return when (DebugConfig.getNetMode()) {
|
||||
DebugConfig.NET_MODE_DEV -> TMC_HOST_TEST
|
||||
DebugConfig.NET_MODE_QA -> TMC_HOST_TEST
|
||||
DebugConfig.NET_MODE_DEMO -> TMC_HOST_DEMO
|
||||
else -> TMC_HOST_PRODUCT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.mogo.module.share.manager
|
||||
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.map.search.traffic.IMogoTrafficSearchListener
|
||||
import com.mogo.map.search.traffic.MogoTrafficResult
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
import com.mogo.module.common.entity.RoadTrafficStatus
|
||||
import com.mogo.module.common.entity.UploadTrafficEntity
|
||||
import com.mogo.module.share.TanluServiceManager
|
||||
import com.mogo.module.share.net.TrafficModelData
|
||||
import com.mogo.utils.logger.Logger
|
||||
import java.util.*
|
||||
|
||||
class TrafficUploadManager : IMogoTrafficSearchListener {
|
||||
|
||||
companion object {
|
||||
|
||||
const val TAG = "TrafficUploadManager"
|
||||
const val TRAFFIC_SEARCH_AREA = 500
|
||||
|
||||
const val TRACK_UPLOAD_INVOKE = "Mogoer_Upload_Traffic_Invoke"
|
||||
|
||||
val trafficUpload by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
TrafficUploadManager()
|
||||
}
|
||||
}
|
||||
|
||||
private val trafficModelData = TrafficModelData()
|
||||
|
||||
fun verityTrafficStatus() {
|
||||
val trafficSearchApi = TanluServiceManager.getMapService().trafficSearchApi
|
||||
val location = TanluServiceManager.getLocationClient().lastKnowLocation
|
||||
trafficSearchApi.registerTrafficSearchListener(this)
|
||||
Logger.d(TAG, "verityTrafficStatus searchTrafficByCircleArea")
|
||||
trafficSearchApi.searchTrafficByCircleArea(MogoLatLng(location.latitude, location.longitude), TRAFFIC_SEARCH_AREA)
|
||||
}
|
||||
|
||||
override fun onTrafficSearchError(errorMsg: String?) {
|
||||
errorMsg?.let {
|
||||
Logger.d(TAG, "onTrafficSearchError errorMsg : $errorMsg , So drop this verity and track")
|
||||
val map = hashMapOf<String, Any>("upload" to 2) //调用高德接口失败
|
||||
MogoApisHandler.getInstance().apis.analyticsApi.track(TRACK_UPLOAD_INVOKE, map)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTrafficSearchInfo(trafficResult: MogoTrafficResult?) {
|
||||
val map = hashMapOf<String, Any>("upload" to 1) //调用高德接口成功
|
||||
MogoApisHandler.getInstance().apis.analyticsApi.track(TRACK_UPLOAD_INVOKE, map)
|
||||
trafficResult?.let {
|
||||
val uploadTrafficEntity = UploadTrafficEntity()
|
||||
val roadTrafficStatusList: MutableList<RoadTrafficStatus> = ArrayList()
|
||||
val trafficStatusInfoList = it.trafficStatusInfos
|
||||
trafficStatusInfoList.forEach { info ->
|
||||
val roadTrafficStatus = RoadTrafficStatus()
|
||||
roadTrafficStatus.angle = info.angle
|
||||
roadTrafficStatus.direction = info.direction
|
||||
roadTrafficStatus.isSegment = false
|
||||
roadTrafficStatus.length = 0
|
||||
roadTrafficStatus.roadName = info.name
|
||||
roadTrafficStatus.status = info.status.toInt()
|
||||
roadTrafficStatus.mogoLatLngList = info.mogoLatLngs
|
||||
roadTrafficStatusList.add(roadTrafficStatus)
|
||||
}
|
||||
uploadTrafficEntity.roadTrafficStatuses = roadTrafficStatusList
|
||||
trafficModelData.uploadTrafficInfo(uploadTrafficEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.mogo.commons.voice.AIAssist
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.module.common.entity.MarkerPoiTypeEnum
|
||||
import com.mogo.module.share.R
|
||||
import com.mogo.module.share.TanluManager
|
||||
import com.mogo.module.share.constant.ShareConstants.*
|
||||
import com.mogo.service.share.TanluUploadParams
|
||||
import com.mogo.utils.NetworkUtils
|
||||
@@ -70,10 +69,10 @@ object UploadHelper {
|
||||
|
||||
private fun showVoiceTip(context: Context, type: String) {
|
||||
var shareItemSum = SharedPrefsMgr.getInstance(context).getInt(KEY_CLICK_SHARE_ITEM_BUTTON, 0)
|
||||
var intervalTime = SharedPrefsMgr.getInstance(context).getLong(KEY_CLICK_SHARE_ITEM_TIME, 0)
|
||||
val intervalTime = SharedPrefsMgr.getInstance(context).getLong(KEY_CLICK_SHARE_ITEM_TIME, 0)
|
||||
if (shareItemSum < VOICE_ALERT_COUNT) {
|
||||
Log.d("UploadHelper", "shareItemSum = $shareItemSum --- intervalTime = $intervalTime --type = ${type}")
|
||||
var time = System.currentTimeMillis()
|
||||
val time = System.currentTimeMillis()
|
||||
if (intervalTime == 0.toLong()) {
|
||||
SharedPrefsMgr.getInstance(context).putLong(KEY_CLICK_SHARE_ITEM_TIME, time)
|
||||
SharedPrefsMgr.getInstance(context).putInt(KEY_CLICK_SHARE_ITEM_BUTTON, ++shareItemSum)
|
||||
@@ -93,8 +92,7 @@ object UploadHelper {
|
||||
|
||||
|
||||
private fun getTypeName(type: String): String? {
|
||||
var typeName = ""
|
||||
typeName = when (type) {
|
||||
return when (type) {
|
||||
MarkerPoiTypeEnum.TRAFFIC_CHECK -> "交通检查"
|
||||
MarkerPoiTypeEnum.ROAD_CLOSED -> "封路"
|
||||
MarkerPoiTypeEnum.FOURS_ROAD_WORK -> "施工"
|
||||
@@ -106,7 +104,6 @@ object UploadHelper {
|
||||
MarkerPoiTypeEnum.FOURS_LIVING -> "实时路况"
|
||||
else -> "实时路况"
|
||||
}
|
||||
return typeName
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,6 +42,6 @@ interface ShareApiService {
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/yycp-launcherSnapshot/launcherSnapshot/searchRoadEventsSync")
|
||||
fun queryRoadInfos(@FieldMap params: Map<String, Object>): Observable<BaseDataCompat<RoadInfos>>
|
||||
fun queryRoadInfos(@FieldMap params: Map<String, Any>): Observable<BaseDataCompat<RoadInfos>>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mogo.module.share.net;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.FieldMap;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface TrafficApiService {
|
||||
/**
|
||||
* 上报路况拥堵情况
|
||||
*
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/yycp-tmcServer/tmcServer/car/reportTraffic/v1")
|
||||
Observable<BaseData> UploadCongestionInfo(@FieldMap Map<String, Object> parames);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.mogo.module.share.net;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.network.ParamsProvider;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.module.common.entity.RoadTrafficStatus;
|
||||
import com.mogo.module.common.entity.UploadTrafficEntity;
|
||||
import com.mogo.module.share.constant.HttpConstant;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static com.mogo.commons.AbsMogoApplication.getApp;
|
||||
|
||||
public class TrafficModelData {
|
||||
|
||||
private static final String TAG = "TrafficModelData";
|
||||
private TrafficApiService mTrafficApiService;
|
||||
|
||||
public TrafficModelData() {
|
||||
IMogoNetwork network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(getApp().getApplicationContext());
|
||||
mTrafficApiService = network.create(TrafficApiService.class, HttpConstant.getTMCHost());
|
||||
}
|
||||
|
||||
/**
|
||||
* 拥堵信息上报
|
||||
*
|
||||
* @param uploadTrafficEntity 高的返回的拥堵信息对象
|
||||
* @param
|
||||
*/
|
||||
public void uploadTrafficInfo(UploadTrafficEntity uploadTrafficEntity) {
|
||||
|
||||
final ParamsProvider.Builder builder = new ParamsProvider.Builder( getApp().getApplicationContext());
|
||||
Map<String, Object> parameters = builder.build();
|
||||
parameters.put("sn", Utils.getSn());
|
||||
parameters.put("data",GsonUtil.jsonFromObject(uploadTrafficEntity));
|
||||
mTrafficApiService.UploadCongestionInfo(parameters)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create( getApp().getApplicationContext())) {
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.d(TAG, "拥堵上报失败" + e.toString());
|
||||
// callback.UploadFail(e.getMessage(), -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
Logger.d(TAG, "拥堵上报成功" + o.toString());
|
||||
// callback.UpLoadSuccess(o.msg.toString(), o.code);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService
|
||||
val params = ArrayMap<String, Any>()
|
||||
params["speed"] = average.toInt()
|
||||
val body = RequestBody.create(MediaType.parse("Content-type:application/json;charset=UTF-8"), GsonUtil.jsonFromObject(params))
|
||||
val disposable = apis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendAverageSpeedForBlockStrategy(body, Utils.getSn()).subscribeOn(Schedulers.io()).subscribe(object : SubscribeImpl<AverateSpeedResponse>(RequestOptions.create(context)) {
|
||||
apis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendAverageSpeedForBlockStrategy(body, Utils.getSn()).subscribeOn(Schedulers.io()).subscribe(object : SubscribeImpl<AverateSpeedResponse>(RequestOptions.create(context)) {
|
||||
override fun onSuccess(response: AverateSpeedResponse?) {
|
||||
super.onSuccess(response)
|
||||
response?.let {
|
||||
|
||||
Reference in New Issue
Block a user