Commit 1937c989 authored by Matheus Horstmann's avatar Matheus Horstmann 🐴
Browse files

Add progress bar


Signed-off-by: Matheus Horstmann's avatarMatheus Horstmann <mch15@inf.ufpr.br>
parent 8931c5c9
......@@ -11,6 +11,7 @@ import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.util.HashMap;
......@@ -279,6 +280,47 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
return values;
}
@Override
public void setProgressBar(boolean enabled) {
ProgressBar pb_login = (ProgressBar) findViewById(R.id.pb_signupact);
if (enabled) {
pb_login.setVisibility(View.VISIBLE);
et_name.setEnabled(false);
et_birthday.setEnabled(false);
et_cep.setEnabled(false);
et_address.setEnabled(false);
et_neighborhood.setEnabled(false);
et_city.setEnabled(false);
et_state.setEnabled(false);
et_email.setEnabled(false);
et_password_confirm.setEnabled(false);
et_phone.setEnabled(false);
et_rg.setEnabled(false);
et_cpf.setEnabled(false);
et_password.setEnabled(false);
btn_signup.setEnabled(false);
} else {
pb_login.setVisibility(View.INVISIBLE);
et_name.setEnabled(true);
et_birthday.setEnabled(true);
et_cep.setEnabled(true);
et_address.setEnabled(true);
et_neighborhood.setEnabled(true);
et_city.setEnabled(true);
et_state.setEnabled(true);
et_email.setEnabled(true);
et_password_confirm.setEnabled(true);
et_phone.setEnabled(true);
et_rg.setEnabled(true);
et_cpf.setEnabled(true);
et_password.setEnabled(true);
btn_signup.setEnabled(true);
}
}
}
......
......@@ -58,6 +58,7 @@ public class SignupPresenter extends BasePresenter<SignupView> {
body.get("password_confirmation"), body.get("name"), body.get("phone1"), body.get("rg"), body.get("cep"));
Call<AccountOutput> listCall = service.signUp(user);
signupPresenter.view().setProgressBar(true);
listCall.enqueue(new Callback<AccountOutput>() {
......@@ -67,13 +68,15 @@ public class SignupPresenter extends BasePresenter<SignupView> {
int status = response.code();
AccountOutput accountOutput = response.body();
switch (status) {
case 422:
// TODO: Add error message
signupPresenter.view().setProgressBar(false);
break;
case 201:
signupPresenter.view().setProgressBar(false);
onSuccessfulSignUp(accountOutput, headers);
Intent intent = new Intent(context, HomeActivity.class);
context.startActivity(intent);
break;
......@@ -84,6 +87,7 @@ public class SignupPresenter extends BasePresenter<SignupView> {
@Override
public void onFailure(Call<AccountOutput> call, Throwable t) {
signupPresenter.view().setProgressBar(true);
}
});
......
......@@ -11,6 +11,8 @@ public interface SignupView {
boolean validateData();
void setProgressBar(boolean enabled);
}
This diff is collapsed.
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