use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.
the class EditLegacyModuleControllerActivity method clearDevice.
/**
* Sets device to a non-attached device (name "NO DEVICE ATTACHED" and name field grayed out).
* Removes the button if necessary.
*
* @param itemView - the view that holds all the necessary UI elements
*/
@Override
protected void clearDevice(View itemView) {
TextView portNumber = (TextView) itemView.findViewById(R.id.portNumber);
int port = Integer.parseInt(portNumber.getText().toString());
EditText nameText = (EditText) itemView.findViewById(R.id.editTextResult);
nameText.setEnabled(false);
nameText.setText(disabledDeviceName());
DeviceConfiguration newModule = new DeviceConfiguration(BuiltInConfigurationType.NOTHING);
newModule.setPort(port);
setModule(newModule);
setButtonVisibility(port, View.GONE);
}
use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.
the class EditLegacyModuleControllerActivity method changeDevice.
/**
* Updates the module behind the scenes to the type that was selected on the spinner.
*
* @param itemView - - the view that holds all the necessary UI elements
* @param type - the new type that was just selected
*/
@Override
protected void changeDevice(View itemView, ConfigurationType type) {
TextView portNumber = (TextView) itemView.findViewById(R.id.portNumber);
int port = Integer.parseInt(portNumber.getText().toString());
EditText nameText = (EditText) itemView.findViewById(R.id.editTextResult);
DeviceConfiguration currentModule = devices.get(port);
nameText.setEnabled(true);
clearNameIfNecessary(nameText, currentModule);
if (type == BuiltInConfigurationType.MOTOR_CONTROLLER || type == BuiltInConfigurationType.SERVO_CONTROLLER || type == BuiltInConfigurationType.MATRIX_CONTROLLER) {
createController(port, type);
setButtonVisibility(port, View.VISIBLE);
} else {
currentModule.setConfigurationType(type);
if (type == BuiltInConfigurationType.NOTHING) {
currentModule.setEnabled(false);
} else {
currentModule.setEnabled(true);
}
setButtonVisibility(port, View.GONE);
}
if (DEBUG) {
DeviceConfiguration module = devices.get(port);
RobotLog.e("[changeDevice] modules.get(port) name: " + module.getName() + ", port: " + module.getPort() + ", type: " + module.getConfigurationType());
}
}
use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.
the class EditMatrixControllerActivity method addCheckBoxListenerOnPort.
private void addCheckBoxListenerOnPort(final int port, View info_port, List<? extends DeviceConfiguration> list) {
final EditText name;
name = (EditText) info_port.findViewById(R.id.editTextResult);
final DeviceConfiguration device;
device = list.get(port - 1);
CheckBox checkbox = (CheckBox) info_port.findViewById(R.id.checkbox_port);
checkbox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (((CheckBox) view).isChecked()) {
name.setEnabled(true);
name.setText("");
device.setEnabled(true);
device.setName("");
} else {
name.setEnabled(false);
device.setEnabled(false);
device.setName(disabledDeviceName());
name.setText(disabledDeviceName());
}
}
});
}
use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.
the class EditPortListCheckboxActivity method handleDisabledDeviceByIndex.
protected void handleDisabledDeviceByIndex(int index) {
View itemView = findViewByIndex(index);
CheckBox checkbox = (CheckBox) itemView.findViewById(idItemCheckbox);
DeviceConfiguration device = this.itemList.get(index);
if (device.isEnabled()) {
checkbox.setChecked(true);
EditText name = (EditText) itemView.findViewById(idItemEditTextResult);
name.setText(device.getName());
} else {
// kind of a hack. Sets the checkbox to true, so
checkbox.setChecked(true);
// when performing the click programmatically,
// the checkbox becomes "unclicked" which does the right thing.
checkbox.performClick();
}
}
use of com.qualcomm.robotcore.hardware.configuration.DeviceConfiguration in project robotcode by OutoftheBoxFTC.
the class EditPortListSpinnerActivity method clearDevice.
@Override
protected void clearDevice(View itemView) {
TextView textViewPortNumber = (TextView) itemView.findViewById(this.idItemPortNumber);
int portNumber = Integer.parseInt(textViewPortNumber.getText().toString());
EditText nameText = (EditText) itemView.findViewById(this.idItemEditTextResult);
nameText.setEnabled(false);
nameText.setText(disabledDeviceName());
DeviceConfiguration config = findConfigByPort(portNumber);
config.setEnabled(false);
}
Aggregations