[2.14.0] wait to finish
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package com.mogo.eagle.core.function.v2x
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.eagle.core.data.v2x.LineUploadData
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.events.network.V2XRefreshModel
|
||||
import com.mogo.eagle.core.function.v2x.road.V2XEventServiceApi
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class LineUploadManager private constructor(context: Context) {
|
||||
|
||||
companion object {
|
||||
|
||||
private const val TAG = "LineUploadManager"
|
||||
|
||||
@Volatile
|
||||
private var lineUploadManager: LineUploadManager? = null
|
||||
|
||||
@Synchronized
|
||||
fun getInstance(context: Context): LineUploadManager? {
|
||||
if (lineUploadManager == null) {
|
||||
synchronized(V2XRefreshModel::class.java) {
|
||||
if (lineUploadManager == null) {
|
||||
lineUploadManager = LineUploadManager(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return lineUploadManager
|
||||
}
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
init {
|
||||
mContext = context
|
||||
}
|
||||
|
||||
private var lineId: Long? by Delegates.observable(
|
||||
CallerAutoPilotStatusListenerManager
|
||||
.getAutoPilotStatusInfo().autopilotControlParameters?.autoPilotLine?.lineId
|
||||
) { _, _, newValue ->
|
||||
CallerLogger.d(TAG, " old line : $lineId , new line : $newValue")
|
||||
lineId = newValue
|
||||
// uploadLine()
|
||||
}
|
||||
|
||||
private fun uploadLine() {
|
||||
lineId?.let {
|
||||
val lineUploadData = LineUploadData(it, MoGoAiCloudClientConfig.getInstance().sn)
|
||||
disposable = MoGoRetrofitFactory.getInstance(HostConst.getHost()) //todo 改域名
|
||||
.create(V2XEventServiceApi::class.java)
|
||||
.uploadLineId(lineUploadData)
|
||||
.retry(3)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { data ->
|
||||
CallerLogger.d(TAG, " uploadLine : $data")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
mContext = null
|
||||
disposable?.dispose()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,12 +19,17 @@ class V2XProvider : IV2XEventProvider {
|
||||
override val functionName: String
|
||||
get() = "V2XProvider"
|
||||
|
||||
|
||||
private var mContext:Context? = null
|
||||
|
||||
override fun init(context: Context) {
|
||||
mContext = context
|
||||
CallerTrafficLightManager.getTrafficLightProvider().initTrafficLightServer(context)
|
||||
VipCarManager.INSTANCE.initServer(context)
|
||||
SpeedLimitDataManager.getInstance().start()
|
||||
TrafficLightDispatcher.INSTANCE.initServer(context)
|
||||
SpeedLimitDispatcher.INSTANCE.initLimit(context)
|
||||
LineUploadManager.getInstance(context)
|
||||
|
||||
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
//不处理
|
||||
@@ -47,7 +52,9 @@ class V2XProvider : IV2XEventProvider {
|
||||
} else {
|
||||
V2XEventManager.onDestroy()
|
||||
}
|
||||
|
||||
mContext?.let {
|
||||
LineUploadManager.getInstance(it)?.onDestroy()
|
||||
}
|
||||
// RedLightWarningManager.INSTANCE.onDestroy()
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import okhttp3.RequestBody;
|
||||
public class V2XRefreshModel {
|
||||
|
||||
private Context mContext;
|
||||
private static V2XRefreshModel mV2XRefreshModel;
|
||||
private static volatile V2XRefreshModel mV2XRefreshModel;
|
||||
|
||||
private V2XRefreshModel() {
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.mogo.eagle.core.function.v2x.road
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.data.v2x.LineUploadData
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Query
|
||||
import retrofit2.http.*
|
||||
|
||||
interface V2XEventServiceApi {
|
||||
|
||||
@GET("/eagleEye-mis/config/queryV2NInformation")
|
||||
fun queryAllV2XEventsByLineId(@Query("lineId") lineId: String, @Query("sn") sn: String): Observable<V2XEventResult>
|
||||
|
||||
@Headers("Content-type:application/json;charset=UTF-8" )
|
||||
@POST( "" )
|
||||
fun uploadLineId(@Body lineId: LineUploadData): Observable<BaseData>
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user