refactor updateGUI
@@ -91,6 +91,22 @@ public class RobotInfoFragment extends ControlsFragment {
binding.robotIcon.setImageResource(R.drawable.ic_openbot);
break;
}
+ } else {
+ binding.robotTypeInfo.setText(getString(R.string.n_a));
+ binding.robotIcon.setImageResource(R.drawable.ic_openbot);
+ binding.voltageInfo.setText(R.string.voltage);
+ binding.speedInfo.setText(R.string.rpm);
+ binding.sonarInfo.setText(R.string.distance);
+ vehicle.setHasVoltageDivider(false);
+ vehicle.setHasSonar(false);
+ vehicle.setHasIndicators(false);
+ vehicle.setHasLedsFront(false);
+ vehicle.setHasLedsBack(false);
+ vehicle.setHasLedsStatus(false);
+ vehicle.setHasBumpSensor(false);
+ vehicle.setHasWheelOdometryFront(false);
+ vehicle.setHasWheelOdometryBack(false);
+ }
binding.voltageSwitch.setChecked(vehicle.isHasVoltageDivider());
binding.sonarSwitch.setChecked(vehicle.isHasSonar());
binding.indicatorLedsSwitch.setChecked(vehicle.isHasIndicators());
@@ -100,22 +116,7 @@ public class RobotInfoFragment extends ControlsFragment {
binding.bumpersSwitch.setChecked(vehicle.isHasBumpSensor());
binding.wheelOdometryFrontSwitch.setChecked(vehicle.isHasWheelOdometryFront());
binding.wheelOdometryBackSwitch.setChecked(vehicle.isHasWheelOdometryBack());
- } else {
- binding.robotTypeInfo.setText(getString(R.string.n_a));
- binding.robotIcon.setImageResource(R.drawable.ic_openbot);
- binding.voltageSwitch.setChecked(false);
- binding.sonarSwitch.setChecked(false);
- binding.indicatorLedsSwitch.setChecked(false);
- binding.ledsFrontSwitch.setChecked(false);
- binding.ledsBackSwitch.setChecked(false);
- binding.ledsStatusSwitch.setChecked(false);
- binding.bumpersSwitch.setChecked(false);
- binding.wheelOdometryFrontSwitch.setChecked(false);
- binding.wheelOdometryBackSwitch.setChecked(false);
- binding.voltageInfo.setText(R.string.voltage);
- binding.speedInfo.setText(R.string.rpm);
- binding.sonarInfo.setText(R.string.distance);
- }
+
if (vehicle.isHasLedsFront() && vehicle.isHasLedsBack()) {
binding.ledsLabel.setVisibility(View.VISIBLE);
binding.lightsSlider.setVisibility(View.VISIBLE);
