Commit 23bd3e45 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Bug fix: App used to crash if opened from 'recents' list

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 36e02d4f
......@@ -368,8 +368,8 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
@Override
......
......@@ -84,8 +84,8 @@ public class CepActivity extends AppCompatActivity implements CepView {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
@Override
......
......@@ -65,7 +65,7 @@ public class CepNotFoundActivity extends AppCompatActivity implements CepNotFoun
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
}
......@@ -84,7 +84,6 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
}
@Override
protected void onResume() {
super.onResume();
......@@ -98,11 +97,10 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
citizensPresenter.unbindView();
}
@Override
protected void onStart() {
super.onStart();
public void onSaveInstanceState(Bundle outState) {
PresenterManager.getInstance().savePresenter(citizensPresenter, outState);
super.onSaveInstanceState(outState);
}
public void showLayout(boolean enabled) {
......
......@@ -59,10 +59,9 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
presenter = new HomePresenter(this);
} else {
}else{
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
}
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.agendador_toolbar);
......@@ -181,8 +180,8 @@ public class HomeActivity extends AppCompatActivity implements HomeView,
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
@Override
......
......@@ -135,8 +135,8 @@ public class LoginActivity extends AppCompatActivity implements LoginView {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
@Override
......
......@@ -37,8 +37,8 @@ public class MainActivity extends AppCompatActivity implements MainView {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
@Override
......
......@@ -193,6 +193,13 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
scheduleConfirmationPresenter.unbindView();
}
@Override
public void onSaveInstanceState(Bundle outState) {
PresenterManager.getInstance().savePresenter(scheduleConfirmationPresenter, outState);
super.onSaveInstanceState(outState);
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Intent intent;
......
......@@ -338,6 +338,13 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
schedulingPresenter.unbindView();
}
@Override
public void onSaveInstanceState(Bundle outState) {
PresenterManager.getInstance().savePresenter(schedulingPresenter, outState);
super.onSaveInstanceState(outState);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
......
......@@ -128,8 +128,8 @@ public class SignupActivity extends AppCompatActivity implements SignupView {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
PresenterManager.getInstance().savePresenter(presenter, outState);
super.onSaveInstanceState(outState);
}
public void loadCepData() {
......
......@@ -120,6 +120,13 @@ public class TermActivity extends AppCompatActivity implements TermView {
termPresenter.unbindView();
}
@Override
public void onSaveInstanceState(Bundle outState) {
PresenterManager.getInstance().savePresenter(termPresenter, outState);
super.onSaveInstanceState(outState);
}
@Override
public void showLayout(boolean enabled) {
......
......@@ -76,6 +76,7 @@ public class AccountPresenter extends BasePresenter<AccountView> {
switch (status) {
case 200:
//info downloaded
Log.v("Server response", this.getClass().getName() + ": 200 - Sucesso!");
onSuccessfulCheck(accountOutput, headers);
accountPresenter.view().setProgressBar(false);
accountPresenter.view().successfulUpdate();
......@@ -83,6 +84,7 @@ public class AccountPresenter extends BasePresenter<AccountView> {
accountPresenter.view().enableButtonSync(true);
break;
default:
Log.e("Server response", this.getClass().getName() + ": 404 - Falha!");
accountPresenter.view().setProgressBar(false);
accountPresenter.view().enableAllFields(false);
accountPresenter.view().enableButtonEdit(false);
......@@ -94,16 +96,16 @@ public class AccountPresenter extends BasePresenter<AccountView> {
@Override
public void onFailure(Call<AccountOutput> call, Throwable t) {
Log.e("Server response", this.getClass().getName() + ": Sem conexão!");
accountPresenter.view().setProgressBar(false);
accountPresenter.view().setNoConnection(true);
accountPresenter.view().enableAllFields(false);
accountPresenter.view().enableButtonEdit(false);
accountPresenter.view().enableButtonSync(true);
accountPresenter.view().setNoConnection(true);
}
});
}
private void onSuccessfulUpdate(AccountOutput accountOutput, Headers headers) {
updateToken(headers);
private void onSuccessfulUpdate(AccountOutput accountOutput) {
accountOutput.getCitizen().save(context);
//cancelling job because photo has been updated from app.
......@@ -164,26 +166,23 @@ public class AccountPresenter extends BasePresenter<AccountView> {
Headers headers = response.headers();
int status = response.code();
AccountOutput accountOutput = response.body();
updateToken(headers);
switch (status) {
case 404:
Log.e("Server response", this.getClass().getName() + ": 404 - Falha!");
accountPresenter.view().setProgressBar(false);
accountPresenter.view().setConnectionError(true);
break;
case 422:
Log.e("Server response", this.getClass().getName() + ": 422 - Erro na requisição!");
accountPresenter.view().showPasswordWarning();
accountPresenter.view().setProgressBar(false);
updateToken(headers);
break;
case 200:
Log.d("Server response", this.getClass().getName() + ": 200 - Sucesso!");
onSuccessfulUpdate(accountOutput, headers);
onSuccessfulUpdate(accountOutput);
accountPresenter.view().setProgressBar(false);
accountPresenter.view().successfulUpdate();
break;
default:
Log.e("Server response", this.getClass().getName() + ": "+ status +" - Falha!");
accountPresenter.view().setProgressBar(false);
accountPresenter.view().setConnectionError(true);
break;
}
}
......
......@@ -19,14 +19,4 @@
<include layout="@layout/content_home" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="56dp"
android:layout_height="56dp"
android:scaleType="center"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:srcCompat="@drawable/ic_action_search"
app:backgroundTint="@color/colorGreen" />
</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
......@@ -31,7 +31,7 @@
<string name="invalid_cpf">CPF inválido</string>
<string name="terms_description">Passo 1 de 3 - Termo de Compromisso</string>
<string name="terms_text">Caso efetue o agendamento e não compareça ao local do atendimento no dia e horário agendado, uma falta será registrada para você no setor do agendamento escolhido. Cada setor possui um número máximo de faltas, ultrapassar esse limite dentro de 90 dias, irá bloquear que você solicite agendamentos pela internet pelos próximos 20 dias.</string>
<string name="terms_limits">Os setores e seus respectivos <b> limites de faltas </b> estão listados abaixo:</string>
<string name="terms_limits">Os setores e seus respectivos <b>limites de faltas</b> estão listados abaixo:</string>
<string name="not_accept">Não Concordo</string>
<string name="accept_continue">Concordar e Continuar</string>
<string name="login_name">Agendador de Serviços Públicos</string>
......@@ -150,9 +150,7 @@
<string name="scheduling_type_hint">Selecione o tipo</string>
<string name="scheduling_location_hint">Selecione o local</string>
<string name="list_item_absences">Limite de faltas: </string>
<string name="dialog_term_error">Ocorreu um erro ao carregar, por favor:
* Verifique sua conexão com a internet;
* tente novamente mais tarde.</string>
<string name="dialog_term_error">Ocorreu um erro ao carregar, por favor:\n* Verifique sua conexão com a internet;\n* Ou ente novamente mais tarde.</string>
<string name="citizen_description">Selecione quem será atendido:</string>
<string name="no_available_hint">Nenhum Disponível</string>
<string name="schedule_time_dialog">Selecione o horário do atendimento:</string>
......
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