18034727885
2026-06-23 b0612e15e9b03870bbb41d385b11a3262e4a8403
修复问题
13个文件已修改
226 ■■■■■ 已修改文件
app/src/main/java/com/xw/yunwei/push/MessageHandler.kt 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/task/accident/detail/AccidentDetailVM.kt 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/task/create/CreateTaskActivity.kt 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/task/selectCar/SelectCarAdapter.kt 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/work/AMapFragment.kt 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/work/car/detail/CarDetailVM.kt 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/work/car/detail/dispatch/DispatchFragment.kt 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/work/car/detail/management/ManagementFragment.kt 1 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/work/car/manage/CarManageActivity.kt 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/work/site/SiteAdapter.kt 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/work/site/SiteNavActivity.kt 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/ui/work/site/SiteNavVM.kt 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_site_nav.xml 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/xw/yunwei/push/MessageHandler.kt
@@ -136,6 +136,7 @@
            }
            9, 10 -> { // 变更协议内容
                if (strategy == 9 && isPush) return
                if (strategy == 9) {
                    currentShowActivity.startActivity(
                        Intent(currentShowActivity, ProtocolActivity::class.java)
app/src/main/java/com/xw/yunwei/ui/task/accident/detail/AccidentDetailVM.kt
@@ -252,7 +252,7 @@
                2 -> {
                    hadCheckTrunkStatus.postValue(false)
                    hadTrunkOpened.postValue(false)
                    hadTrunkOpened.postValue(true)
                }
            }
        }
app/src/main/java/com/xw/yunwei/ui/task/create/CreateTaskActivity.kt
@@ -31,7 +31,6 @@
import com.xw.common.base.ImageEventListener
import com.xw.common.base.ImageSelectAdapter
import com.xw.common.base.ShowImgListDialog
import com.xw.common.utils.BindUtils.getResColor
import com.xw.common.utils.GpsHelper
import com.xw.common.utils.KeyPreferences
import com.xw.common.utils.MMKVManager
@@ -356,34 +355,9 @@
        )
        binding.name.text = item.plateNumber
        binding.color.text = "${item.vehicleColor} | 车身编码:${item.vehicleCode}"
        val setStatus: (Int, Int) -> Unit = { text, bg ->
            binding.status.setTextColor(text)
            binding.status.setBackgroundResource(bg)
        }
        // 1=运营中 2=维修中 3=已收车 4=车辆异常
        when (item.operatingStatus) {
            1 -> {
                setStatus(getResColor(R.color.blue_5), R.color.blue_1)
                binding.status.text = "运营中"
            }
            2 -> {
                setStatus(getResColor(R.color.red_5), R.color.red_1)
                binding.status.text = "维修中"
            }
            3 -> {
                setStatus(getResColor(R.color.gray_7), R.color.gray_3)
                binding.status.text = "已收车"
            }
            4 -> {
                setStatus(getResColor(R.color.orange_5), R.color.orange_1)
                binding.status.text = "车辆异常"
            }
        }
        binding.status.setTextColor(item.getShowStatusTextColor().colorIdToColorValue(this))
        binding.status.setBackgroundResource(item.getShowStatusBgResource())
        binding.status.text=item.getShowStatus()
    }
    /**
app/src/main/java/com/xw/yunwei/ui/task/selectCar/SelectCarAdapter.kt
@@ -6,11 +6,11 @@
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xw.common.base.OnItemClickListener
import com.xw.common.utils.BindUtils.getResColor
import com.xw.common.utils.BindUtils.getUrl
import com.xw.common.viewAdapter.ImageDefault
import com.xw.common.viewAdapter.ViewAdapter
import com.xw.yunwei.R
import com.xw.yunwei.databinding.ItemSelectCarBinding
import com.xw.yunwei.extension.colorIdToColorValue
import com.xw.yunwei.model.CarModel
/**
@@ -35,43 +35,9 @@
            ViewAdapter.loadImage(binding.icon, ImageDefault(item.getShowVehiclePicture(), R.mipmap.img_work_car))
            binding.name.text = item.plateNumber
            binding.color.text = "${item.vehicleColor} | 车身编码:${item.vehicleCode}"
            // 初始化状态文本颜色与背景
            val setStatus: (Int, Int) -> Unit = { text, bg ->
                binding.status.setTextColor(text)
                binding.status.setBackgroundResource(bg)
            }
            // 1=运营中 2=维修中 3=已收车 4=车辆异常
            when (item.operatingStatus) {
                1 -> {
                    setStatus(
                        getResColor(com.xw.common.R.color.blue_5), com.xw.common.R.color.blue_1
                    )
                    binding.status.text = "运营中"
                }
                2 -> {
                    setStatus(
                        getResColor(com.xw.common.R.color.red_5), com.xw.common.R.color.red_1
                    )
                    binding.status.text = "维修中"
                }
                3 -> {
                    setStatus(
                        getResColor(com.xw.common.R.color.gray_7), com.xw.common.R.color.gray_3
                    )
                    binding.status.text = "已收车"
                }
                4 -> {
                    setStatus(
                        getResColor(com.xw.common.R.color.orange_5), com.xw.common.R.color.orange_1
                    )
                    binding.status.text = "车辆异常"
                }
            }
            binding.status.setBackgroundResource(item.getShowStatusBgResource())
            binding.status.setTextColor(item.getShowStatusTextColor().colorIdToColorValue(it.root.context))
            binding.status.text=item.getShowStatus()
            // 选中状态高亮:变更背景与文字颜色
            if (item.id == selectCar?.id) {
app/src/main/java/com/xw/yunwei/ui/work/AMapFragment.kt
@@ -3,6 +3,7 @@
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.Point
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
@@ -299,6 +300,10 @@
    /*==========================对外============================*/
    fun setCurrentZoom(zoom: Float) {
        currentZoom = zoom
    }
    /* 移动到当前定位 */
    fun moveToLocation() {
        locationMarker?.let {
@@ -319,6 +324,26 @@
        }
    }
    fun animateTo(latitude: Double, longitude: Double, zoom: Float = currentZoom, targetScreenYRatio: Float = 0.5f) {
        lifecycleScope.launchWhenResumed {
            val map = aMap ?: return@launchWhenResumed
            val height = mapView?.height ?: 0
            if (height == 0 || targetScreenYRatio == 0.5f) {
                val update = CameraUpdateFactory.newLatLngZoom(LatLng(latitude, longitude), zoom)
                map.animateCamera(update, 300, null)
                return@launchWhenResumed
            }
            // Analytically compute the camera offset so the marker lands at targetScreenYRatio
            // This avoids depending on current projection which would stack offsets on repeated calls
            val deltaYPixels = height * (0.5f - targetScreenYRatio)
            val metersPerPixel = 156543.03392 * Math.cos(Math.toRadians(latitude)) / Math.pow(2.0, zoom.toDouble())
            val deltaLat = deltaYPixels * metersPerPixel / 111320.0
            val targetLatLng = LatLng(latitude + deltaLat, longitude)
            val update = CameraUpdateFactory.newLatLngZoom(targetLatLng, zoom)
            map.animateCamera(update, 300, null)
        }
    }
    /* 绘制电子围栏 */
    fun drawPolygon(areas: List<List<LatLng>>) {
        lifecycleScope.launchWhenResumed {
app/src/main/java/com/xw/yunwei/ui/work/car/detail/CarDetailVM.kt
@@ -201,7 +201,7 @@
                2 -> {
                    hadCheckTrunkStatus.postValue(false)
                    hadTrunkOpened.postValue(false)
                    hadTrunkOpened.postValue(true)
                }
            }
        }
app/src/main/java/com/xw/yunwei/ui/work/car/detail/dispatch/DispatchFragment.kt
@@ -38,7 +38,7 @@
        super.setObservable()
        viewModel.carInfo.observe(this) {
            initBasicInfo(it)
            if (it.operatingStatus == 1) {
            if (it.isWorking()) {
                resetSlideView(binding.slideView1, DIRECTION_LEFT, "左滑收车")
            } else {
                resetSlideView(binding.slideView1, DIRECTION_RIGHT, "右滑发车")
@@ -104,7 +104,7 @@
        with(binding.slideView1) {
            setOnSlideCompleteListener {
                viewModel.carInfo.value?.also { carModel ->
                    val setStatus = if (carModel.operatingStatus == 1) 3 else 1
                    val setStatus = if (carModel.isWorking()) 3 else 1
                    if (setStatus == 3) {
                        viewModel.getAllAcceptCarPoints(error = {
                            binding.slideView1.animateReset()
app/src/main/java/com/xw/yunwei/ui/work/car/detail/management/ManagementFragment.kt
@@ -6,6 +6,7 @@
import androidx.core.os.bundleOf
import com.xw.common.CommonDialog
import com.xw.common.base.BaseFragmentNoVM
import com.xw.common.utils.BindUtils.getUrl
import com.xw.common.utils.BindUtils.getResColor
import com.xw.common.viewAdapter.ImageDefault
import com.xw.common.viewAdapter.ViewAdapter
app/src/main/java/com/xw/yunwei/ui/work/car/manage/CarManageActivity.kt
@@ -133,6 +133,7 @@
            if (location == null) {
                CommonDialog.showLocationNotGrantedTipsDialog(this@CarManageActivity)
            } else {
                // TODO ... FATAL BUG: 当服务不可用,isNullOrEmpty永远为true时,这里会被1秒调一次去请求
                if (viewModel.fences.value.isNullOrEmpty()) {
                    val cityCode = location.adCode.substring(0, 4) + "00"
                    viewModel.getFenceByCode(cityCode)
@@ -162,7 +163,7 @@
            mapFrag.clearMarks()
            it.forEach {
                val resId =
                    if (it.operatingStatus == 1) com.xw.yunwei.R.mipmap.ic_map_car_g else com.xw.yunwei.R.mipmap.ic_map_car_r
                    if (it.isWorking()) com.xw.yunwei.R.mipmap.ic_map_car_g else com.xw.yunwei.R.mipmap.ic_map_car_r
                mapFrag.drawCustomMarker(
                    LatLng(it.latitude ?: 0.0, it.longitude ?: 0.0),
                    resId,
app/src/main/java/com/xw/yunwei/ui/work/site/SiteAdapter.kt
@@ -39,11 +39,12 @@
            }
            it.parent.setOnClickListener { listener.onItemClick(item) }
            it.nav.setOnClickListener { listener.oneItemElementClick(item) }
//            if (item == selectItem) {
//                it.parent.setBackgroundColor(getResColor(com.xw.common.R.color.gray_3))
//            } else {
            // 与 @苏清禾 确认,选择的样式恢复回来
            if (item == selectItem) {
                it.parent.setBackgroundColor(getResColor(com.xw.common.R.color.gray_3))
            } else {
                it.parent.setBackgroundColor(getResColor(com.xw.common.R.color.white))
//            }
            }
            binding.name.text = item.pointName
            binding.address.text = item.pointAddress
app/src/main/java/com/xw/yunwei/ui/work/site/SiteNavActivity.kt
@@ -25,6 +25,7 @@
import com.xw.common.utils.BindUtils.getUrl
import com.xw.common.utils.GlideEngine
import com.xw.common.utils.GpsHelper.Companion.navigate
import com.xw.common.utils.ToastUtilCommon
import com.xw.common.viewAdapter.ViewAdapter.Companion.showAnim
import com.xw.yunwei.BR
import com.xw.yunwei.BaseBusinessActivity
@@ -49,6 +50,7 @@
        }
    }
    private var filterDialog: MaterialDialog? = null
    private var pendingMarkerId: String? = null
    val mapFrag: AMapFragment by lazy { AMapFragment() }
    private val bottomSheetBehavior: BottomSheetBehavior<LinearLayout> by lazy {
@@ -128,6 +130,16 @@
                    0.65f
                )
            }
            pendingMarkerId?.let { id ->
                it.find { item -> "${item.id}" == id }?.let { selected ->
                    adapter.selectItem = selected
                    animateMapTo(selected.pointLat ?: 0.0, selected.pointLon ?: 0.0)
                    mapFrag.findMarkerById("${selected.id ?: ""}")?.let { marker ->
                        mapFrag.clickMarker(marker)
                    }
                }
                pendingMarkerId = null
            }
        }
        viewModel.siteItem.observe(this) { setPointInfo() }
        viewModel.fences.observe(this) {
@@ -170,12 +182,19 @@
            }
        }
        binding.arrow.setOnClickListener { toggleBottomSheetState() }
        binding.location.setOnClickListener { mapFrag.moveToLocation() }
        binding.location.setOnClickListener {
            // mapFrag.moveToLocation()
            mapFrag.getLocation()?.let { it ->
                mapFrag.setCurrentZoom(16f)
                mapFrag.animateTo(it.latitude, it.longitude)
            } ?: run { ToastUtilCommon.showWarn("未获取到定位信息") }
        }
        mapFrag.locationChangeCallback = { location ->
            dismissDialog()
            if (location == null) {
                CommonDialog.showLocationNotGrantedTipsDialog(this@SiteNavActivity)
            } else {
                // TODO ... FATAL BUG: 当服务不可用,isNullOrEmpty永远为true时,这里会被1秒调一次去请求
                if (viewModel.fences.value.isNullOrEmpty()) {
                    viewModel.cityCode = location.adCode.substring(0, 4) + "00"
                    viewModel.getFenceByCode()
@@ -185,9 +204,13 @@
        }
        mapFrag.markerClickCallback = { id ->
            adapter.data.find { "${it.id}" == id }?.let {
                /*
                adapter.remove(it)
                adapter.addData(0, it)
                adapter.selectItem = it
                */
                pendingMarkerId = id
                viewModel.query(it.pointLat, it.pointLon)
            }
        }
        binding.btnErrorUpload.setOnClickListener {
@@ -207,11 +230,11 @@
            isHideable = false
            skipCollapsed = false  // 允许进入折叠状态
            halfExpandedRatio = 0.62f
            halfExpandedRatio = 0.58f
            // 展开时距离顶部距离(留出状态栏和搜索区域)
            // expandedOffset = resources.getDimensionPixelSize(R.dimen.dp_50)
            expandedOffset = 0 // 顶部有定位图标占位 暂不需要设置
            expandedOffset = resources.getDimensionPixelSize(R.dimen.dp_50)
            // expandedOffset = 0 // 顶部有定位图标占位 暂不需要设置
            addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
                override fun onStateChanged(bottomSheet: View, newState: Int) {
@@ -250,6 +273,7 @@
                            else -> {}
                        }
                    }
                    updateLocationIconY(bottomSheet)
                }
                override fun onSlide(bottomSheet: View, slideOffset: Float) {
@@ -261,8 +285,12 @@
//                            binding.arrow.rotation = 360f * (0.5f - slideOffset)
//                        }
//                    }
                    updateLocationIconY(bottomSheet)
                }
            })
            // 初始位置:等布局完成后更新 location 按钮
            binding.bottomSheet.post { updateLocationIconY(binding.bottomSheet) }
        }
    }
@@ -289,6 +317,14 @@
            .start()
    }
    private fun updateLocationIconY(bottomSheet: View) {
        val coordinator = bottomSheet.parent as? View ?: return
        val sheetTop = bottomSheet.top + coordinator.top
        val locHeight = binding.location.height
        if (locHeight == 0) return
        val marginBottom = resources.getDimensionPixelSize(R.dimen.dp_12)
        binding.location.y = (sheetTop - locHeight - marginBottom).toFloat()
    }
    private fun initAdapter() {
        binding.siteRv.adapter = adapter
@@ -425,6 +461,11 @@
        }
    }
    private fun animateMapTo(latitude: Double, longitude: Double) {
        val ratio = if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_HALF_EXPANDED) 0.55f else 0.5f
        mapFrag.animateTo(latitude, longitude, targetScreenYRatio = ratio)
    }
    override fun onBackPressedHandel() {
        if (viewModel.siteItem.value == null) {
            super.onBackPressedHandel()
app/src/main/java/com/xw/yunwei/ui/work/site/SiteNavVM.kt
@@ -33,7 +33,7 @@
        return selectStatus.count { it != filterStatus[0] } > 0
    }
    fun query() {
    fun query(lat: Double? = null, lon: Double? = null) {
        launchRequest {
            val map = mutableMapOf<String, Any?>()
            // 运营状态 1=待启用 2=启用中 3=已停用 4=已失效
@@ -45,8 +45,13 @@
//            map["pointType"] = null  // 点位类型1运营点位 2测试点位
            map["queryParams"] = search.value  // 查询参数
            map["cityCode"] = cityCode
            map["longitude"] = Constants.longitude
            map["latitude"] = Constants.latitude
            if (lat != null && lon != null) {
                map["longitude"] = lon
                map["latitude"] = lat
            } else {
                map["longitude"] = Constants.longitude
                map["latitude"] = Constants.latitude
            }
            workRepository.querySites(map)?.let {
                val data = it.toMutableList()
                if (it.isNotEmpty()) {
app/src/main/res/layout/activity_site_nav.xml
@@ -135,20 +135,10 @@
                android:orientation="vertical"
                app:behavior_fitToContents="false"
                app:behavior_halfExpandedRatio="0.58"
                app:behavior_peekHeight="@dimen/dp_92"
                app:behavior_peekHeight="@dimen/dp_54"
                app:behavior_skipCollapsed="false"
                app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
                tools:behavior_peekHeight="@dimen/dp_500">
                <androidx.appcompat.widget.AppCompatImageView
                    android:id="@+id/location"
                    android:layout_width="@dimen/dp_32"
                    android:layout_height="@dimen/dp_32"
                    android:layout_gravity="end"
                    android:layout_marginEnd="@dimen/dp_12"
                    android:layout_marginBottom="@dimen/dp_12"
                    android:elevation="2dp"
                    android:src="@drawable/svg_location1" />
                <LinearLayout
                    android:layout_width="match_parent"
@@ -158,16 +148,22 @@
                    android:orientation="vertical">
                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/dp_50">
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/dp_50">
                        <androidx.appcompat.widget.AppCompatImageView
                            android:id="@+id/arrow"
                            android:layout_width="@dimen/dp_24"
                            android:layout_height="@dimen/dp_24"
                            android:layout_centerInParent="true"
                            android:background="@drawable/svg_arrow_d1" />
                        <RelativeLayout
                                android:id="@+id/arrow"
                                android:layout_width="@dimen/dp_50"
                                android:layout_height="@dimen/dp_50"
                                android:layout_centerInParent="true">
                            <androidx.appcompat.widget.AppCompatImageView
                                    android:layout_width="@dimen/dp_24"
                                    android:layout_height="@dimen/dp_24"
                                    android:layout_centerInParent="true"
                                    android:background="@drawable/svg_arrow_d1" />
                        </RelativeLayout>
                    </RelativeLayout>
                    <androidx.core.widget.NestedScrollView
@@ -196,6 +192,17 @@
        </androidx.coordinatorlayout.widget.CoordinatorLayout>
        <androidx.appcompat.widget.AppCompatImageView
            android:id="@+id/location"
            android:layout_width="@dimen/dp_32"
            android:layout_height="@dimen/dp_32"
            android:layout_marginEnd="@dimen/dp_12"
            android:layout_marginBottom="@dimen/dp_12"
            android:elevation="@dimen/dp_2"
            android:src="@drawable/svg_location1"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent" />
        <View
            android:id="@+id/filterOverlay"
            android:layout_width="0dp"