@Override protected void onStart() { super.onStart(); utility.updateHeader( Utility.NO_FILE, R.string.pref_hardware_config_filename, R.id.active_filename, R.id.included_header); Intent intent = getIntent(); Serializable extra = intent.getSerializableExtra(EDIT_MOTOR_CONTROLLER_CONFIG); if (extra != null) { motorControllerConfigurationConfig = (MotorControllerConfiguration) extra; motors = (ArrayList<DeviceConfiguration>) motorControllerConfigurationConfig.getMotors(); motor1 = (MotorConfiguration) motors.get(0); motor2 = (MotorConfiguration) motors.get(1); controller_name.setText(motorControllerConfigurationConfig.getName()); motor1_name.setText(motor1.getName()); motor2_name.setText(motor2.getName()); addListenerOnPort1(); handleDisabledMotor(motor1, checkbox_motor1); addListenerOnPort2(); handleDisabledMotor(motor2, checkbox_motor2); } }
private void m139c() { Intent intent = new Intent(); ArrayList arrayList = new ArrayList(); if (this.f190g) { MotorConfiguration motorConfiguration = new MotorConfiguration(this.f194k.getText().toString()); motorConfiguration.setEnabled(true); motorConfiguration.setPort(1); arrayList.add(motorConfiguration); } else { arrayList.add(new MotorConfiguration(1)); } if (this.f191h) { motorConfiguration = new MotorConfiguration(this.f195l.getText().toString()); motorConfiguration.setEnabled(true); motorConfiguration.setPort(2); arrayList.add(motorConfiguration); } else { arrayList.add(new MotorConfiguration(2)); } this.f185b.addMotors(arrayList); this.f185b.setName(this.f189f.getText().toString()); intent.putExtra(EDIT_MOTOR_CONTROLLER_CONFIG, this.f185b); setResult(-1, intent); finish(); }
private void m133a(MotorConfiguration motorConfiguration, CheckBox checkBox) { if (motorConfiguration.getName().equals("NO DEVICE ATTACHED") || motorConfiguration.getType() == ConfigurationType.NOTHING) { checkBox.setChecked(true); checkBox.performClick(); return; } checkBox.setChecked(true); }
private void handleDisabledMotor(MotorConfiguration motor, CheckBox checkbox) { if (motor.getName().equals(DeviceConfiguration.DISABLED_DEVICE_NAME) || motor.getType() == DeviceConfiguration.ConfigurationType.NOTHING) { checkbox.setChecked(true); // kind of a hack. Sets the checkbox to true, so // when performing the click programmatically, // the checkbox becomes "unclicked" which does the right thing. checkbox.performClick(); } else { checkbox.setChecked(true); } }
private void saveState() { Intent returnIntent = new Intent(); ArrayList<DeviceConfiguration> motors = new ArrayList<>(); if (motor1Enabled) { String name = motor1_name.getText().toString(); MotorConfiguration newMotor = new MotorConfiguration(name); newMotor.setDisabled(false); newMotor.setPort(1); motors.add(newMotor); } else { motors.add(new MotorConfiguration(1)); } // add disabled motor if (motor2Enabled) { String name = motor2_name.getText().toString(); MotorConfiguration newMotor = new MotorConfiguration(name); newMotor.setDisabled(false); newMotor.setPort(2); motors.add(newMotor); } else { motors.add(new MotorConfiguration(2)); } // add disabled motor motorControllerConfigurationConfig.addMotors(motors); motorControllerConfigurationConfig.setName(controller_name.getText().toString()); returnIntent.putExtra(EDIT_MOTOR_CONTROLLER_CONFIG, motorControllerConfigurationConfig); setResult(RESULT_OK, returnIntent); finish(); }