修改设置速度按钮

This commit is contained in:
lixiaopeng
2022-11-11 17:11:22 +08:00
parent 6ec0f08275
commit 9707137c21
3 changed files with 43 additions and 27 deletions

View File

@@ -7,6 +7,7 @@ import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Process
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
@@ -113,51 +114,45 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
// if (maxAcceleration > 0) {
// tvAcceleration.text = "加速度 $maxAcceleration m/s²"
// }
tvAcceleration.text = "每次调整车速±5km/h"
tvAcceleration.text = "每次调整车速±5km/h,点击确定生效"
if (speedLimit > 0) {
tvSpeed.text = speedLimit.toString()
}else{
tvSpeed.text = "0"
}
ivSpeedReduce.setOnClickListener {
if(speedLimit>=5){
speedLimit -= 5
//速度显示
val isSuccess = CallerAutoPilotManager.setAutoPilotSpeed(speedLimit)
when {
isSuccess -> {
//速度显示
tvSpeed.text = speedLimit.toString()
ToastUtils.showShort("车速设置成功,立即生效")
}
else -> {
ToastUtils.showShort("设置车速失败,请启动域控制器")
}
}
tvSpeed.text = speedLimit.toString()
}else{
ToastUtils.showShort("车速不能再减了")
}
}
ivSpeedAdd.setOnClickListener {
if(speedLimit<=55){
speedLimit += 5
//速度显示
val isSuccess = CallerAutoPilotManager.setAutoPilotSpeed(speedLimit)
when {
isSuccess -> {
//速度显示
tvSpeed.text = speedLimit.toString()
ToastUtils.showShort("车速设置成功,立即生效")
}
else -> {
ToastUtils.showShort("设置车速失败,请启动域控制器")
}
}
tvSpeed.text = speedLimit.toString()
}else{
ToastUtils.showShort("车速不能再加了")
}
}
//速度确认
tvSureModify.setOnClickListener {
val isSuccess = CallerAutoPilotManager.setAutoPilotSpeed(speedLimit)
when {
isSuccess -> {
//速度显示
tvSpeed.text = speedLimit.toString()
ToastUtils.showShort("车速设置成功,立即生效")
}
else -> {
ToastUtils.showShort("设置车速失败,请启动域控制器")
}
}
}
initOchView()
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="24px"/>
<solid android:color="#1E3062" />
</shape>

View File

@@ -241,6 +241,7 @@
/>
<TextView
android:id="@+id/tvUnit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="km/h"
@@ -249,8 +250,22 @@
app:layout_constraintTop_toTopOf="@id/ivSpeedAdd"
app:layout_constraintBottom_toBottomOf="@id/ivSpeedAdd"
app:layout_constraintLeft_toRightOf="@id/ivSpeedAdd"
android:layout_marginStart="40px"
/>x`
android:layout_marginStart="40px" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvSureModify"
android:layout_width="200px"
android:layout_height="135px"
android:background="@drawable/taxi_loginout_sure_bg"
android:gravity="center"
android:text="确定"
android:textColor="@android:color/white"
android:textSize="42px"
android:layout_marginLeft="50px"
app:layout_constraintTop_toTopOf="@id/tvSpeed"
app:layout_constraintBottom_toBottomOf="@id/tvSpeed"
app:layout_constraintLeft_toRightOf="@id/tvUnit"
tools:visibility="visible" />
<TextView
android:id="@+id/tvAcceleration"