I'm using the MVP standard in my Android project.
In my MainActivity I have the following components:
private Paciente paciente;
private EditText nome, cpf, cpfTutor, telefone;
private CheckBox checkbox;
Soon after, I have this method that starts when you click a button:
private void initPaciente() {
paciente = new Paciente();
paciente.setNome(nome.getText().toString());
paciente.setCpfTitular(cpf.getText().toString());
paciente.setCpfTutor(cpfTutor.getText().toString());
paciente.setTelefone(telefone.getText().toString());
paciente.setDataCadastro("27/01/2017");
paciente.setStatus(status.getSelectedItem().toString().toLowerCase());
paciente.setTimestamp(new Timestamp(System.currentTimeMillis()).getTime());
paciente.save;
}
Well, if I understood the concept of MVP well, this type of direct access to the patient object is not valid.
How do I access these EditText nome, cpf, cpfTutor, telefone;
components by Presenter?
I tried to access it like this:
private PacienteActivity activity = (PacienteActivity) getContext();
Paciente paciente = new Paciente();
paciente.setNome(activity.nome.getText().toString());
// ...
But this way I have to leave the attributes as public (which I do not think is cool), or create a lot of geters that will pollute my code.