[6.5.0]自动探查修改
This commit is contained in:
@@ -23,9 +23,15 @@ import com.mogo.eagle.core.function.hmi.R
|
||||
class AutomaticExplorationAdapter(val context: Context,val user: Int): RecyclerView.Adapter<AutomaticExplorationAdapter.ExplorationHolder>() {
|
||||
|
||||
private var data: List<AutoExplorationEntity> ?= null
|
||||
private var completeListener: CompleteListener ?= null
|
||||
|
||||
fun setData(data: List<AutoExplorationEntity>){
|
||||
this.data = data
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setListener(listener: CompleteListener){
|
||||
completeListener = listener
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ExplorationHolder {
|
||||
@@ -44,15 +50,17 @@ class AutomaticExplorationAdapter(val context: Context,val user: Int): RecyclerV
|
||||
|
||||
override fun onBindViewHolder(holder: ExplorationHolder, position: Int) {
|
||||
data?.let {
|
||||
holder.tvExplorationContent.text = it[position].explorationContent
|
||||
val entity = it[position]
|
||||
holder.tvExplorationContent.text = entity.explorationContent
|
||||
val rotationAnim = ObjectAnimator.ofFloat(holder.ivExplorationLoading, "rotation", 0f, 360f)
|
||||
rotationAnim.repeatCount = it[position].explorationDuration.toInt()/1000
|
||||
rotationAnim.repeatCount = entity.explorationDuration.toInt()/1000
|
||||
rotationAnim.repeatMode = ValueAnimator.RESTART
|
||||
rotationAnim.duration = 1000
|
||||
rotationAnim.interpolator = LinearInterpolator()
|
||||
rotationAnim.addListener(object: AnimatorListenerAdapter(){
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
super.onAnimationEnd(animation)
|
||||
completeListener?.onComplete(entity)
|
||||
if(user == 0){
|
||||
holder.ivExplorationLoading.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
@@ -77,4 +85,8 @@ class AutomaticExplorationAdapter(val context: Context,val user: Int): RecyclerV
|
||||
var tvExplorationContent: TextView = itemView.findViewById(R.id.tvExplorationContent)
|
||||
}
|
||||
|
||||
interface CompleteListener{
|
||||
fun onComplete(entity: AutoExplorationEntity)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.mogo.commons.voice.AIAssist
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotSummaryInfo
|
||||
import com.mogo.eagle.core.data.notice.AutoExplorationEntity
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.CountDownTimer
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
|
||||
|
||||
@@ -37,7 +38,7 @@ class AutomaticExplorationView @JvmOverloads constructor(
|
||||
|
||||
companion object {
|
||||
private const val TAG = "AutomaticExplorationView"
|
||||
private const val EXPLORATION_SHOW_TIME = 10000L //自动探查弹窗展示时间
|
||||
private const val EXPLORATION_SHOW_TIME = 5000L //探查完毕后,5秒关闭弹窗
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -54,20 +55,13 @@ class AutomaticExplorationView @JvmOverloads constructor(
|
||||
LayoutInflater.from(context).inflate(R.layout.view_automatic_exploration_p, this, true)
|
||||
}
|
||||
initEvent()
|
||||
initData()
|
||||
}
|
||||
|
||||
fun showAutoExploration(){
|
||||
//倒计时
|
||||
|
||||
//语音播放
|
||||
AIAssist.getInstance(context).speakTTSVoice("道路畅通一切正常蘑菇行车助手将持续守候您的出行")
|
||||
|
||||
//隐藏自动探查视图
|
||||
private fun showAutoExploration(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
this@AutomaticExplorationView.visibility = View.GONE
|
||||
this@AutomaticExplorationView.visibility = View.VISIBLE
|
||||
initData()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initEvent(){
|
||||
@@ -78,15 +72,6 @@ class AutomaticExplorationView @JvmOverloads constructor(
|
||||
rotationAnim?.cancel()
|
||||
this.visibility = View.GONE
|
||||
}
|
||||
//启动扫描
|
||||
ivScan?.let {
|
||||
rotationAnim = ObjectAnimator.ofFloat(it, "rotation", 0f, 360f)
|
||||
rotationAnim?.repeatCount = ValueAnimator.INFINITE
|
||||
rotationAnim?.repeatMode = ValueAnimator.RESTART
|
||||
rotationAnim?.duration = 2000
|
||||
rotationAnim?.interpolator = LinearInterpolator()
|
||||
rotationAnim?.start()
|
||||
}
|
||||
rvExplorationList = findViewById(R.id.rvExplorationList)
|
||||
val linearLayoutManager = LinearLayoutManager(context)
|
||||
linearLayoutManager.orientation = LinearLayoutManager.VERTICAL
|
||||
@@ -96,16 +81,47 @@ class AutomaticExplorationView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
val dataList = ArrayList<AutoExplorationEntity>()
|
||||
dataList.add(AutoExplorationEntity("当前道路事件分析",2000L))
|
||||
dataList.add(AutoExplorationEntity("前方车辆",2000L))
|
||||
dataList.add(AutoExplorationEntity("两侧车辆",3000L))
|
||||
dataList.add(AutoExplorationEntity("后方车辆",3000L))
|
||||
dataList.add(AutoExplorationEntity("前方路口车辆流速分析",4000L))
|
||||
dataList.add(AutoExplorationEntity("前方路口行人/非机动车分析",4000L))
|
||||
dataList.add(AutoExplorationEntity("路侧视频分析",5000L))
|
||||
automaticExplorationAdapter?.setData(dataList)
|
||||
val dataList = ArrayList<AutoExplorationEntity>(7)
|
||||
dataList.add(AutoExplorationEntity("当前道路事件分析",2000L,false))
|
||||
dataList.add(AutoExplorationEntity("前方车辆",2000L,false))
|
||||
dataList.add(AutoExplorationEntity("两侧车辆",2600L,false))
|
||||
dataList.add(AutoExplorationEntity("后方车辆",3000L,false))
|
||||
dataList.add(AutoExplorationEntity("前方路口车辆流速分析",4000L,false))
|
||||
dataList.add(AutoExplorationEntity("前方路口行人/非机动车分析",4300L,false))
|
||||
dataList.add(AutoExplorationEntity("路侧视频分析",5000L,false))
|
||||
automaticExplorationAdapter?.setListener(object: AutomaticExplorationAdapter.CompleteListener{
|
||||
override fun onComplete(entity: AutoExplorationEntity) {
|
||||
var allComplete = true //所有探查项目都探查完毕
|
||||
dataList.forEach {
|
||||
if(it.explorationContent == entity.explorationContent){
|
||||
it.explorationComplete = true
|
||||
}
|
||||
if(!it.explorationComplete){
|
||||
allComplete = false
|
||||
}
|
||||
}
|
||||
if(allComplete){
|
||||
//语音播放
|
||||
AIAssist.getInstance(context).speakTTSVoice("道路畅通一切正常蘑菇行车助手将持续守候您的出行")
|
||||
//5秒后关闭弹窗
|
||||
val hideViewTimer =object: CountDownTimer(EXPLORATION_SHOW_TIME,EXPLORATION_SHOW_TIME){
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
//隐藏自动探查视图
|
||||
ThreadUtils.runOnUiThread {
|
||||
this@AutomaticExplorationView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
hideViewTimer.start()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
automaticExplorationAdapter?.setData(dataList)
|
||||
//每出现一次自动探查,增加相应的服务次数
|
||||
//车辆服务次数
|
||||
AutopilotSummaryInfo.vehicleServiceNum += 31
|
||||
@@ -117,6 +133,15 @@ class AutomaticExplorationView @JvmOverloads constructor(
|
||||
AutopilotSummaryInfo.vulnerableTipNum += 4
|
||||
//消除安全风险隐患次数
|
||||
AutopilotSummaryInfo.dangerNum += 24
|
||||
//启动扫描
|
||||
ivScan?.let {
|
||||
rotationAnim = ObjectAnimator.ofFloat(it, "rotation", 0f, 360f)
|
||||
rotationAnim?.repeatCount = ValueAnimator.INFINITE
|
||||
rotationAnim?.repeatMode = ValueAnimator.RESTART
|
||||
rotationAnim?.duration = 2000
|
||||
rotationAnim?.interpolator = LinearInterpolator()
|
||||
rotationAnim?.start()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
|
||||
Reference in New Issue
Block a user