`public class AddEmployeeActivity extends AppCompatActivity {
EditText name, email, password, specialty, salary;
Spinner type;
Button addButton;
EmployeeService employeeService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.admin_activity_add_employee);
name = findViewById(R.id.AddEmployeeName300);
email = findViewById(R.id.AddEmployeeEmail300);
password = findViewById(R.id.AddEmployeePassword300);
specialty = findViewById(R.id.AddSpeciality300);
salary = findViewById(R.id.AddEmployeeSalary300);
type = findViewById(R.id.DropDownMenu300);
addButton = findViewById(R.id.AddNewEmployeeButton300);
// Inyección de dependencias
employeeService = new EmployeeService(new FirebaseEmployeeRepository(), new EmployeeValidatorImpl());
addButton.setOnClickListener(v -> {
Employee employee = new Employee(
"generatedId",
name.getText().toString(),
email.getText().toString(),
password.getText().toString(),
specialty.getText().toString(),
salary.getText().toString(),
type.getSelectedItem().toString()
);
if (employeeService.addEmployee(employee)) {
Toast.makeText(this, "Employee Added Successfully", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Validation Failed", Toast.LENGTH_SHORT).show();
}
});
'
}`
Clase modificada
}
}`