[6.5.0] merge
This commit is contained in:
@@ -70,6 +70,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidxroomktx
|
||||
implementation rootProject.ext.dependencies.view_model_scope
|
||||
implementation rootProject.ext.dependencies.lifecycle_extension
|
||||
implementation rootProject.ext.dependencies.androidxrecyclerview
|
||||
|
||||
implementation project(':foudations:mogo-commons')
|
||||
implementation project(':core:mogo-core-res')
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.mogo.eagle.core.function.business.roadcross
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.data.road.CameraDeviceInfo
|
||||
@@ -14,6 +16,7 @@ import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.view.CameraMarkerView
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.map.overlay.core.Level
|
||||
import com.mogo.map.overlay.point.Point
|
||||
@@ -26,6 +29,7 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
companion object {
|
||||
|
||||
private const val TAG = "RoadCrossCameraManager"
|
||||
private const val REMOVE_MARKER_DELAY_TIME = 10_000L
|
||||
|
||||
val instance: RoadCrossCameraManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
RoadCrossCameraManager()
|
||||
@@ -42,18 +46,24 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
|
||||
private val overlayManager = CallerMapUIServiceManager.getOverlayManager()
|
||||
|
||||
private val handler = object :Handler(Looper.getMainLooper()){
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
overlayManager?.removeAllPointsInOwner(TAG)
|
||||
}
|
||||
}
|
||||
|
||||
fun init(context: Context?) {
|
||||
mContext = context
|
||||
CallerMapRoadListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
//todo 记录方法执行时间
|
||||
private var distance: Double by Delegates.observable(0.0) { _, _, newV ->
|
||||
if (!isCameraRequest && newV < 100) {
|
||||
isCameraRequest = true
|
||||
val roadCrossEnd = CallerMapRoadListenerManager.getCrossInfo()?.cross_id_end
|
||||
Log.d(
|
||||
"emArrow",
|
||||
val roadCrossEnd = CallerMapRoadListenerManager.getCrossEndInfo()
|
||||
CallerLogger.d(
|
||||
"$M_MAP$TAG",
|
||||
"触发接口调用 dis: $distance , roadCrossEnd: ${roadCrossEnd ?: "null"} "
|
||||
)
|
||||
if (roadCrossEnd != null) {
|
||||
@@ -69,8 +79,10 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
}
|
||||
roadCrossCameraList = it.deviceInfoList
|
||||
// 地图上打marker(注意marker方向),marker点击获取对应ip
|
||||
it.deviceInfoList.forEach { deviceInfo ->
|
||||
addCameraDeviceMarker(deviceInfo)
|
||||
ThreadUtils.runOnUiThread {
|
||||
it.deviceInfoList.forEach { deviceInfo ->
|
||||
addCameraDeviceMarker(deviceInfo)
|
||||
}
|
||||
}
|
||||
},
|
||||
onError = {
|
||||
@@ -80,12 +92,12 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
traceError("roadCross is null")
|
||||
}
|
||||
} else {
|
||||
Log.d("emArrow", "distance:$distance")
|
||||
CallerLogger.d("$M_MAP$TAG", "distance:$distance")
|
||||
}
|
||||
}
|
||||
|
||||
private fun addCameraDeviceMarker(cameraDeviceInfo: CameraDeviceInfo) {
|
||||
Log.d("emArrow","add marker:${cameraDeviceInfo.deviceIp}")
|
||||
CallerLogger.d("$M_MAP$TAG", "add marker:${cameraDeviceInfo.deviceIp}")
|
||||
mContext?.let {
|
||||
val builder =
|
||||
Point.Options.Builder(TAG, Level.MAP_MARKER)
|
||||
@@ -100,16 +112,16 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
.longitude(cameraDeviceInfo.lon)
|
||||
.latitude(cameraDeviceInfo.lat)
|
||||
.onClick { id ->
|
||||
Log.d("emArrow", "Marker click :$id")
|
||||
CallerLogger.d("$M_MAP$TAG", "Marker click :$id")
|
||||
CallerMapRoadListenerManager.invokeRoadCrossClick()
|
||||
ndeRoadCameraNetWorkModel.singleRequestCrossLive(id,
|
||||
onSuccess = { live ->
|
||||
CallerMapRoadListenerManager.invokeRoadCrossLive(live)
|
||||
},
|
||||
onError = {errorMsg ->
|
||||
onError = { errorMsg ->
|
||||
traceError(" ${cameraDeviceInfo.deviceIp} click request error :$errorMsg")
|
||||
})
|
||||
}
|
||||
CallerLogger.d("$M_MAP$TAG", "new road cross camera=$overlayManager")
|
||||
overlayManager?.showOrUpdatePoint(builder.build())
|
||||
}
|
||||
}
|
||||
@@ -135,32 +147,21 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
|
||||
override fun onRoadChange(cross: Boolean, roadCross: RoadCross?) {
|
||||
super.onRoadChange(cross, roadCross)
|
||||
val data = CameraDeviceInfo("172.18.1.60", 112.582913287, 26.9320508672) //todo emArrow test
|
||||
addCameraDeviceMarker(data)
|
||||
val data1 = CameraDeviceInfo("172.18.1.42", 112.582947017, 26.9328373092)
|
||||
addCameraDeviceMarker(data1)
|
||||
val data2 = CameraDeviceInfo("172.18.1.72", 112.582421, 26.932519)
|
||||
addCameraDeviceMarker(data2)
|
||||
|
||||
// 出路口
|
||||
if (!cross) {
|
||||
// 停止请求摄像头数据
|
||||
ndeRoadCameraNetWorkModel.cancelRequest("roadCross")
|
||||
// 清除marker
|
||||
roadCrossCameraList?.let {
|
||||
it.forEach { camera ->
|
||||
Log.d("emArrow","remove marker:${camera.deviceIp}")
|
||||
overlayManager?.removePoint(camera.deviceIp)
|
||||
}
|
||||
}
|
||||
CallerLogger.d("$M_MAP$TAG", "remove marker")
|
||||
handler.sendEmptyMessageDelayed(0, REMOVE_MARKER_DELAY_TIME)
|
||||
// 释放控制
|
||||
isCameraRequest = false
|
||||
Log.d("emArrow", "经过路口,释放控制")
|
||||
CallerLogger.d("$M_MAP$TAG", "经过路口,释放控制")
|
||||
}
|
||||
}
|
||||
|
||||
private fun traceError(msg: String) {
|
||||
if(DebugConfig.isDebug()){
|
||||
if (DebugConfig.isDebug()) {
|
||||
ToastUtils.showLong(msg)
|
||||
}
|
||||
val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
|
||||
@@ -23,7 +23,8 @@ interface INDERoadCameraApiService {
|
||||
@Header("MogoReqTime") time: String,
|
||||
@Query("roadUniqueId") roadId: String,
|
||||
@Query("lon") lon: Double,
|
||||
@Query("lat") lat: Double
|
||||
@Query("lat") lat: Double,
|
||||
@Query("cityCode") cityCode: String
|
||||
): BaseResponse<List<RoadCrossCamera>>
|
||||
|
||||
// 单ip查询设备直播流与缩略图
|
||||
@@ -33,7 +34,8 @@ interface INDERoadCameraApiService {
|
||||
@Header("MogoReqTime") time: String,
|
||||
@Query("ip") ip: String,
|
||||
@Query("lon") lon: Double,
|
||||
@Query("lat") lat: Double
|
||||
@Query("lat") lat: Double,
|
||||
@Query("cityCode") cityCode: String
|
||||
): BaseResponse<RoadCameraLive>
|
||||
|
||||
// 批量ip查询设备直播流与缩略图
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.road.RoadCameraLive
|
||||
import com.mogo.eagle.core.data.road.RoadCrossCamera
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.apiCall
|
||||
import com.mogo.eagle.core.network.cancel
|
||||
@@ -40,14 +41,15 @@ class NDERoadCameraNetWorkModel private constructor() {
|
||||
pair.second,
|
||||
crossID,
|
||||
loc.longitude,
|
||||
loc.latitude
|
||||
loc.latitude,
|
||||
CallerMapUIServiceManager.getCityCode() ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
onSuccess {
|
||||
if(it.result.isNotEmpty()){
|
||||
if (it.result.isNotEmpty()) {
|
||||
onSuccess.invoke(it.result[0])
|
||||
}else{
|
||||
} else {
|
||||
onError.invoke("getRoadCrossInfo empty camera info")
|
||||
}
|
||||
}
|
||||
@@ -71,7 +73,8 @@ class NDERoadCameraNetWorkModel private constructor() {
|
||||
pair.second,
|
||||
ip,
|
||||
loc.longitude,
|
||||
loc.latitude
|
||||
loc.latitude,
|
||||
CallerMapUIServiceManager.getCityCode() ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -92,10 +95,12 @@ class NDERoadCameraNetWorkModel private constructor() {
|
||||
loader {
|
||||
apiCall {
|
||||
val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
val cityCode = CallerMapUIServiceManager.getCityCode() ?: ""
|
||||
val map = mutableMapOf(
|
||||
"lon" to loc.longitude,
|
||||
"lat" to loc.latitude,
|
||||
"ipList" to list
|
||||
"ipList" to list,
|
||||
"cityCode" to cityCode
|
||||
)
|
||||
val pair = getAuth(BATCH_LIVE)
|
||||
getNetWorkApi().cameraLiveBatchRequest(pair.first, pair.second, map)
|
||||
|
||||
@@ -4,9 +4,9 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
|
||||
import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
|
||||
import com.mogo.eagle.core.function.map.R
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class CameraMarkerView(context: Context, attrs: AttributeSet? = null, defStyleAt
|
||||
)
|
||||
)
|
||||
}
|
||||
modeChange(CallerMoGoUiSettingManager.getDayMode())
|
||||
modeChange(CallerSkinModeListenerManager.getMode())
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
@@ -36,7 +36,9 @@ class CameraMarkerView(context: Context, attrs: AttributeSet? = null, defStyleAt
|
||||
}
|
||||
|
||||
override fun onSkinModeChange(skinMode: Int) {
|
||||
modeChange(skinMode)
|
||||
ThreadUtils.runOnUiThread {
|
||||
modeChange(skinMode)
|
||||
}
|
||||
}
|
||||
|
||||
private fun modeChange(mode: Int) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84Lis
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.MogoMapView
|
||||
import com.mogo.map.overlay.line.Polyline
|
||||
import com.mogo.map.overlay.point.Point
|
||||
@@ -59,10 +60,14 @@ class MapBizView(context: Context?, attrs: AttributeSet?) : MogoMapView(context,
|
||||
//设置倾斜手势是否可用。
|
||||
it.setTiltGesturesEnabled(false)
|
||||
//设置双指缩放手势是否可用。
|
||||
it.setZoomGesturesEnabled(false) //true todo emArrow test
|
||||
it.setZoomGesturesEnabled(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getInstanceTag(): String {
|
||||
return MogoMap.DEFAULT
|
||||
}
|
||||
|
||||
fun getUI(): IMogoMapUIController? {
|
||||
return map?.uiController
|
||||
}
|
||||
@@ -109,10 +114,7 @@ class MapBizView(context: Context?, attrs: AttributeSet?) : MogoMapView(context,
|
||||
}
|
||||
|
||||
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
|
||||
// 跟新地图控件 112.582776,26.931655
|
||||
// gnssInfo.longitude = 112.582776
|
||||
// gnssInfo.latitude = 26.931655 //todo emArrow test
|
||||
// gnssInfo.heading = 15.0
|
||||
// 跟新地图控件
|
||||
setExtraGPSData(gnssInfo)
|
||||
accLimit = gnssInfo.acceleration < accThreshold
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.mogo.eagle.core.function.view
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
|
||||
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider
|
||||
import com.mogo.map.MogoMap.Companion.MAP_ROAM
|
||||
import com.mogo.map.MogoMapView
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController
|
||||
import com.mogo.map.uicontroller.VisualAngleMode
|
||||
|
||||
|
||||
class MapRoamView(context: Context?, attrs: AttributeSet?) : MogoMapView(context, attrs),
|
||||
IMoGoSkinModeChangeListener,
|
||||
LifecycleObserver, IMoGoMapRoadListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MapRoamView"
|
||||
}
|
||||
|
||||
override fun onCreate(bundle: Bundle?) {
|
||||
super.onCreate(bundle)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
initMapView()
|
||||
CallerSkinModeListenerManager.addListener(TAG, this)
|
||||
CallerMapRoadListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun initMapView() {
|
||||
map?.uiController?.showMyLocation(false)
|
||||
map?.uiSettings?.let {
|
||||
it.setAllGesturesEnabled(false)
|
||||
//设置指南针是否可见。
|
||||
it.setCompassEnabled(false)
|
||||
//设置室内地图楼层切换控件是否可见。
|
||||
it.setIndoorSwitchEnabled(false)
|
||||
//设置定位按钮是否可见。
|
||||
it.setMyLocationButtonEnabled(false)
|
||||
//设置比例尺控件是否可见
|
||||
it.setScaleControlsEnabled(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getInstanceTag(): String {
|
||||
return MAP_ROAM
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
private fun getUI(): IMogoMapUIController? {
|
||||
return map?.uiController
|
||||
}
|
||||
|
||||
override fun onSkinModeChange(skinMode: Int) {
|
||||
if (skinMode == 0) {
|
||||
getUI()?.stepInDayMode(false)
|
||||
} else if (skinMode == 1) {
|
||||
getUI()?.stepInDayMode(true)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
this.outlineProvider = TextureVideoViewOutlineProvider(12f)
|
||||
this.clipToOutline = true
|
||||
}
|
||||
|
||||
fun openRoam() {
|
||||
this.onResume()
|
||||
// 更新地图视角 - 高视角
|
||||
getUI()?.changeMapVisualAngle(VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP, null)
|
||||
// 更新路口位置
|
||||
val latLng = CallerMapRoadListenerManager.getStopLineLatLng()
|
||||
Log.i("emArrow","$TAG 开始漫游 latLng:${latLng.toString()}")
|
||||
latLng?.let {
|
||||
val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
loc.latitude = latLng.first
|
||||
loc.longitude = latLng.second
|
||||
setExtraGPSData(loc)
|
||||
}
|
||||
// 开始漫游
|
||||
|
||||
}
|
||||
|
||||
fun closeRoam(){
|
||||
this.onPause()
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
// 先取消注册数据,再onDestroy
|
||||
CallerSkinModeListenerManager.removeListener(TAG)
|
||||
CallerMapRoadListenerManager.removeListener(TAG)
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.mogo.eagle.core.function.view
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.function.map.R
|
||||
import kotlin.random.Random
|
||||
|
||||
|
||||
class RoadCrossRoamListAdapter(private val mContext: Context) : RecyclerView.Adapter<RoadCrossRoamListAdapter.ViewHolder>() {
|
||||
|
||||
private val items: MutableList<String> = mutableListOf()
|
||||
|
||||
init {
|
||||
items.add("前方路况拥堵分析")
|
||||
items.add("路口危险车辆分析")
|
||||
items.add("路口交通事故分析")
|
||||
items.add("路口行人碰撞分析")
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view: View = LayoutInflater.from(mContext).inflate(R.layout.item_road_cross_roam_tip, parent, false)
|
||||
return ViewHolder(view)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return items.size
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val item = items[position]
|
||||
holder.textView.text = item
|
||||
// 随机决定是否显示ProgressBar
|
||||
// if (Random.nextBoolean()) { // 50%的几率显示ProgressBar
|
||||
holder.progressBar.visibility = View.VISIBLE
|
||||
holder.checkIcon.visibility = View.GONE
|
||||
|
||||
val r = Random.nextInt(3,6)
|
||||
// 模拟加载完成
|
||||
holder.itemView.postDelayed({
|
||||
holder.progressBar.visibility = View.GONE
|
||||
holder.checkIcon.visibility = View.VISIBLE
|
||||
},r * 1000L)
|
||||
// } else {
|
||||
// holder.progressBar.visibility = View.GONE
|
||||
// holder.checkIcon.visibility = View.VISIBLE
|
||||
// }
|
||||
}
|
||||
|
||||
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var textView: TextView = itemView.findViewById(R.id.tvRoadItemTip)
|
||||
var progressBar: ProgressBar = itemView.findViewById(R.id.pbRoadItemTip)
|
||||
var checkIcon: ImageView = itemView.findViewById(R.id.ivRoadItemTip)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.mogo.eagle.core.function.view
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
|
||||
import com.mogo.eagle.core.function.map.R
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.zhidaoauto.map.data.road.StopLine
|
||||
import kotlinx.android.synthetic.main.view_road_cross_roam.view.ivCoverRoam
|
||||
import kotlinx.android.synthetic.main.view_road_cross_roam.view.ivRoadRoamClose
|
||||
import kotlinx.android.synthetic.main.view_road_cross_roam.view.lvRoadCrossRoamTip
|
||||
import kotlinx.android.synthetic.main.view_road_cross_roam.view.mapRoamView
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class RoadCrossRoamView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoMapRoadListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "RoadCrossRoamView"
|
||||
}
|
||||
|
||||
private var showState by Delegates.observable(false) { _, oldV, newV ->
|
||||
if (oldV != newV) {
|
||||
updateView(newV)
|
||||
}
|
||||
}
|
||||
|
||||
private var animator: ObjectAnimator? = null
|
||||
|
||||
init {
|
||||
val res = when (CallerSkinModeListenerManager.getMode()) {
|
||||
0 -> R.layout.view_road_cross_roam
|
||||
1 -> R.layout.view_road_cross_roam_light
|
||||
else -> R.layout.view_road_cross_roam
|
||||
}
|
||||
LayoutInflater.from(context).inflate(res, this, true)
|
||||
lvRoadCrossRoamTip.layoutManager = LinearLayoutManager(context)
|
||||
lvRoadCrossRoamTip.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
outRect.bottom = 24
|
||||
}
|
||||
})
|
||||
ivRoadRoamClose.setOnClickListener {
|
||||
detachView()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerMapRoadListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun updateView(state: Boolean) {
|
||||
// 切换线程
|
||||
ThreadUtils.runOnUiThread {
|
||||
if (state) {
|
||||
attachView()
|
||||
} else {
|
||||
detachView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStopLineInfo(info: StopLine) {
|
||||
super.onStopLineInfo(info)
|
||||
showState = info.distance < 200 && info.distance > 100
|
||||
Log.i("emArrow","showState $showState , distance:${info.distance}")
|
||||
}
|
||||
|
||||
private fun attachView() {
|
||||
this.visibility = View.VISIBLE
|
||||
mapRoamView.openRoam()
|
||||
lvRoadCrossRoamTip.adapter = RoadCrossRoamListAdapter(context)
|
||||
// 创建横向移动的动画
|
||||
if (animator == null) {
|
||||
animator =
|
||||
ObjectAnimator.ofFloat(
|
||||
ivCoverRoam,
|
||||
"translationX",
|
||||
-120f,
|
||||
540f
|
||||
)
|
||||
}
|
||||
animator?.duration = 1500 // 设置动画持续时间,单位为毫秒
|
||||
animator?.repeatCount = ValueAnimator.INFINITE // 设置动画无限重复
|
||||
animator?.repeatMode = ValueAnimator.RESTART // 设置动画来回移动
|
||||
animator?.start()
|
||||
}
|
||||
|
||||
private fun detachView() {
|
||||
mapRoamView.closeRoam()
|
||||
lvRoadCrossRoamTip.adapter = null
|
||||
animator?.cancel()
|
||||
this.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
animator?.cancel()
|
||||
CallerMapRoadListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 377 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 996 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_30">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvRoadItemTip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:textSize="@dimen/dp_22"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/pbRoadItemTip"
|
||||
android:layout_width="@dimen/dp_30"
|
||||
android:layout_height="@dimen/dp_30"
|
||||
android:progressDrawable="@drawable/icon_road_roam_progress"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivRoadItemTip"
|
||||
android:layout_width="@dimen/dp_30"
|
||||
android:layout_height="@dimen/dp_30"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/icon_road_roam_tip"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ContentDescription" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_road_cross_roam">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivRoadRoamClose"
|
||||
android:layout_width="@dimen/dp_50"
|
||||
android:layout_height="@dimen/dp_50"
|
||||
android:src="@drawable/icon_road_roam_close"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivZhiRoadRoamView"
|
||||
android:layout_width="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:layout_marginStart="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/bg_road_roam_xiaozhi"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_20"
|
||||
android:layout_marginTop="@dimen/dp_24"
|
||||
android:text="@string/road_cross_roam_tip"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/dp_30"
|
||||
app:layout_constraintLeft_toRightOf="@id/ivZhiRoadRoamView"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.view.MapRoamView
|
||||
android:id="@+id/mapRoamView"
|
||||
android:layout_width="@dimen/dp_540"
|
||||
android:layout_height="@dimen/dp_300"
|
||||
android:layout_marginTop="@dimen/dp_160"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="@dimen/dp_540"
|
||||
android:layout_height="@dimen/dp_300"
|
||||
android:layout_marginTop="@dimen/dp_160"
|
||||
android:layout_marginStart="@dimen/dp_32"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivCoverRoam"
|
||||
android:layout_width="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_300"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:src="@drawable/icon_cover_road_roam"
|
||||
tools:ignore="ContentDescription" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/lvRoadCrossRoamTip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_200"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:layout_marginLeft="@dimen/dp_30"
|
||||
android:layout_marginRight="@dimen/dp_30"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/mapRoamView" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,3 +1,4 @@
|
||||
<resources>
|
||||
<string name="app_name">mogo-core-function-map</string>
|
||||
<string name="road_cross_roam_tip">前方即将进入全息路口\n为您全面扫描潜在风险</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user