opt
This commit is contained in:
@@ -126,10 +126,10 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mMogoMapService.getHostListenerRegister().registerMarkerClickListener( this );
|
||||
}
|
||||
|
||||
// IMogoObuManager obuManager = mServiceApis.getObuManager();
|
||||
// if(obuManager!=null) {
|
||||
// obuManager.registerObuDataChangedListener(EventDispatchCenter.getInstance());
|
||||
// }
|
||||
IMogoObuManager obuManager = mServiceApis.getObuManager();
|
||||
if(obuManager!=null) {
|
||||
obuManager.registerObuDataChangedListener(EventDispatchCenter.getInstance());
|
||||
}
|
||||
|
||||
EventDispatchCenter.getInstance().setMapLoadedCallback( () -> {
|
||||
Logger.d( TAG, "map loaded." + Thread.currentThread().getName() );
|
||||
|
||||
@@ -34,10 +34,7 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.androidxrecyclerview
|
||||
implementation rootProject.ext.dependencies.androidxccorektx
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package com.zhidao.mogo.module.obu
|
||||
|
||||
import com.mogo.service.obu.IMogoObuDataChangedListener
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.zhidao.smartv2x.listener.OnMessageReceiveListener
|
||||
import com.zhidao.smartv2x.model.obu.CarEventInfo
|
||||
import com.zhidao.smartv2x.model.obu.CarLocationInfo
|
||||
import com.zhidao.smartv2x.model.obu.TrafficLightInfo
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Scheduler
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.internal.operators.single.SingleSubscribeOn
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import io.reactivex.schedulers.Schedulers.io
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* 模拟相关操作及数据的单例类
|
||||
@@ -32,21 +30,44 @@ object MockUtil {
|
||||
}
|
||||
|
||||
private fun intervalMockData(){
|
||||
intervalObs = Observable.interval(1000,TimeUnit.MILLISECONDS).map {
|
||||
intervalObs = Observable.interval(5000,TimeUnit.MILLISECONDS).map {
|
||||
it.toString()
|
||||
}.subscribe {
|
||||
val carLocationInfo = CarLocationInfo()
|
||||
carLocationInfo.carId = "carLocation$it"
|
||||
dataCallback.showCarLocationInfo(carLocationInfo)
|
||||
val other = "other$it"
|
||||
dataCallback.showOtherInfo(other)
|
||||
val eventInfo = CarEventInfo()
|
||||
eventInfo.describe = "event des $it"
|
||||
eventInfo.type = "event type $it"
|
||||
dataCallback.showCarEventInfo(eventInfo)
|
||||
val traffic = TrafficLightInfo()
|
||||
traffic.id = "traffic $it"
|
||||
dataCallback.showTrafficLightInfo(traffic)
|
||||
}.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe {
|
||||
val random = Random.nextInt(0, 3)
|
||||
Logger.d(TAG, "random====$random")
|
||||
val carEventInfo = CarEventInfo()
|
||||
when (random) {
|
||||
0->{
|
||||
// 绿波引导
|
||||
carEventInfo.type = ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY.toString()
|
||||
carEventInfo.typeCode = ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY.toString()
|
||||
val r = Random.nextInt(0, 3)
|
||||
carEventInfo.describe = when (r) {
|
||||
0 -> "保持当前车速行驶!"
|
||||
1 -> "建议50km/h车速行驶"
|
||||
else -> "建议30km/h ~ 50km/h 车速行驶"
|
||||
}
|
||||
dataCallback.showCarEventInfo(carEventInfo)
|
||||
}
|
||||
1->{
|
||||
// 前方急刹预警
|
||||
carEventInfo.type = ObuConstant.TYPE_URGENCY_COLLISION_WARNING.toString()
|
||||
carEventInfo.typeCode = ObuConstant.TYPE_URGENCY_COLLISION_WARNING.toString()
|
||||
carEventInfo.describe = "这个应该是随便写,反正也不用"
|
||||
dataCallback.showCarEventInfo(carEventInfo)
|
||||
}
|
||||
2->{
|
||||
// 行人碰撞预警
|
||||
carEventInfo.type = ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING.toString()
|
||||
carEventInfo.typeCode = ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING.toString()
|
||||
carEventInfo.describe = "这个应该是随便写,反正也不用"
|
||||
dataCallback.showCarEventInfo(carEventInfo)
|
||||
}
|
||||
else->{
|
||||
// 其他,不处理
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user