Commit 7b8448a2 authored by Matheus Horstmann's avatar Matheus Horstmann 🐴
Browse files

Add dialog when request return error


Signed-off-by: Matheus Horstmann's avatarMatheus Horstmann <mch15@inf.ufpr.br>
parent dc7dd098
......@@ -129,7 +129,7 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
@Override
public boolean validateData() {
DialogActivity dialog = new DialogActivity();
WarningDialog dialog = new WarningDialog();
FragmentManager manager = getFragmentManager();
if (et_name.getText().toString().replaceAll("\\s+","").isEmpty() ||
Mask.unmask(et_cpf.getText().toString()).isEmpty() ||
......@@ -246,14 +246,28 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
}
public static class DialogActivity extends DialogFragment {
public static class WarningDialog extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.signup_dialog_message) +
builder.setMessage(getString(R.string.signup_warningDialog_message) +
"\n" +
getString(R.string.singup_dialog_message2)).setTitle(getString(R.string.signup_dialog_title))
getString(R.string.singup_warningDialog_message2)).setTitle(getString(R.string.signup_warningDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
// Create the AlertDialog object and return it
return builder.create();
}
}
public static class ErrorDialog extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getString(R.string.signup_erroDialog_message)).setTitle(getString(R.string.signup_errorDialog_title))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
......@@ -280,6 +294,15 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
return values;
}
@Override
public void cpfExists() {
ErrorDialog dialog = new ErrorDialog();
FragmentManager manager = getFragmentManager();
dialog.show(manager,"Cpf");
}
@Override
public void setProgressBar(boolean enabled) {
ProgressBar pb_login = (ProgressBar) findViewById(R.id.pb_signupact);
......
......@@ -71,7 +71,7 @@ public class SignupPresenter extends BasePresenter<SignupView> {
switch (status) {
case 422:
// TODO: Add error message
signupPresenter.view().cpfExists();
signupPresenter.view().setProgressBar(false);
break;
case 201:
......
......@@ -13,6 +13,8 @@ public interface SignupView {
void setProgressBar(boolean enabled);
void cpfExists();
}
......@@ -49,10 +49,10 @@
<string name="signup_invalid_phone">Telefone inválido</string>
<string name="signup_rg">RG*</string>
<string name="invalid_rg">RG inválido</string>
<string name="signup_dialog_message">Algumas informações não foram preenchidas ou estão incorretas no cadastro.</string>
<string name="signup_dialog_title">OPS</string>
<string name="signup_warningDialog_message">Algumas informações não foram preenchidas ou estão incorretas no cadastro.</string>
<string name="signup_warningDialog_title">OPS</string>
<string name="ok">OK</string>
<string name="singup_dialog_message2">"Por favor retorne e preencha novamente. "</string>
<string name="singup_warningDialog_message2">"Por favor retorne e preencha novamente. "</string>
<string name="signup_null_name">Nome vázio</string>
<string name="invalid_birthdate">Data nasc. inválida</string>
<string name="cpf_empty">Cpf vázio</string>
......@@ -61,4 +61,6 @@
<string name="password_doesnt_match">Senhas diferem</string>
<string name="schedules_screen_presentation">Nesta página, você poderá efetuar um agendamento, acompanhar seus atendimentos futuros e verificar seus atendimentos já realizados ou cancelados.</string>
<string name="schedules_more_information">Para mais informações sobre como usar o Sistema Agendador de Serviços Públicos visite o Manual de Utilização ou a Seção de Perguntar Frequentes.</string>
<string name="signup_errorDialog_title">Erro</string>
<string name="signup_erroDialog_message">CPF já cadastrado</string>
</resources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment