[M2] m2 EB5时间错误

This commit is contained in:
wangmingjun
2023-02-27 15:11:02 +08:00
parent 387572900b
commit bfcc3fff30

View File

@@ -2,16 +2,13 @@ package com.mogo.och.bus.passenger.ui
import android.graphics.BitmapFactory
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.os.Message
import android.view.View
import androidx.core.content.ContextCompat
import com.amap.api.maps.model.LatLng
import com.mogo.commons.mvp.MvpFragment
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
import com.mogo.eagle.core.data.msgbox.MsgBoxType
import com.mogo.eagle.core.data.msgbox.NoticeFrCloudMsg
import com.mogo.eagle.core.data.msgbox.V2XMsg
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.function.hmi.ui.setting.ToggleDebugView
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.eagle.core.utilcode.util.DateTimeUtils
@@ -21,6 +18,7 @@ import com.mogo.och.bus.passenger.presenter.PM2DrivingPresenter
import com.mogo.och.common.module.utils.DateTimeUtil.*
import com.mogo.och.common.module.utils.NumberFormatUtil
import kotlinx.android.synthetic.m2.p_m2_driving_info_fragment.*
import java.lang.ref.WeakReference
import kotlin.math.ceil
import kotlin.math.roundToInt
@@ -30,6 +28,9 @@ import kotlin.math.roundToInt
*/
class PM2DrivingInfoFragment :
MvpFragment<PM2DrivingInfoFragment?, PM2DrivingPresenter?>() {
private var timeHandler: TimeHandler? = null
/**
* 改变自动驾驶状态
*
@@ -71,6 +72,8 @@ class PM2DrivingInfoFragment :
// BPRouteDataTestUtils.converToRouteData()
}
updateCurrentTime()
timeHandler = TimeHandler(this)
timeHandler?.sendEmptyMessageDelayed(WHAT_TIME_CURRENT, LOOP_TIME_TEXT)
}
override fun initViews(savedInstanceState: Bundle?) {
@@ -89,6 +92,7 @@ class PM2DrivingInfoFragment :
}
override fun onDestroy() {
timeHandler?.removeCallbacksAndMessages(null)
super.onDestroy()
overMapView.onDestroy()
}
@@ -216,8 +220,27 @@ class PM2DrivingInfoFragment :
"$remainDis$disUnit | $time 分钟".also { remain_mt.text = it }
}
companion object {
private val TAG = PM2DrivingInfoFragment::class.java.simpleName
class TimeHandler(obj: PM2DrivingInfoFragment) : Handler(Looper.getMainLooper()) {
private val mRef: WeakReference<PM2DrivingInfoFragment> = WeakReference(obj)
val drivingInfoFragment = mRef.get() as PM2DrivingInfoFragment
override fun handleMessage(msg: Message) {
mRef.get()?.run {
when (msg.what) {
WHAT_TIME_CURRENT -> {
drivingInfoFragment.updateCurrentTime()
sendEmptyMessageDelayed(
WHAT_TIME_CURRENT, LOOP_TIME_TEXT)
} //可以直接访问Activity中的变量
else -> {}
}
}
}
}
companion object {
private val TAG = PM2DrivingInfoFragment::class.java.simpleName
const val LOOP_TIME_TEXT = 60 * 1000L
const val WHAT_TIME_CURRENT = 10001 //MSG_WHAT
}
}