Commit d6aefeb9 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Issue AGILE#151 Added dialog on connection failure

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 64ba9bd1
......@@ -85,7 +85,7 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
private UserPhotoHelper userPhotoHelper;
private ConnectionErrorDialog dg_connection_error;
private ConnectionErrorDialog connectionErrorDialog;
private final int REQUEST_PERMISSIONS = 1;
......@@ -252,11 +252,11 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
else{
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_cep_connection_error));
if(dg_connection_error == null){
dg_connection_error = new ConnectionErrorDialog();
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
......@@ -277,13 +277,13 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
}
}
else{
if( dg_connection_error == null){
dg_connection_error = new ConnectionErrorDialog();
if( connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_no_connection_message));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
scrollUp();
}
......@@ -866,26 +866,26 @@ public class AccountActivity extends AppCompatActivity implements AccountView {
@Override
public void setNoConnection(boolean enabled){
if(enabled){
if(dg_connection_error == null){
dg_connection_error = new ConnectionErrorDialog();
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
@Override
public void setNoConnectionCep(boolean enabled){
if(enabled){
if(dg_connection_error == null){
dg_connection_error = new ConnectionErrorDialog();
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_cep_connection_error));
dg_connection_error.setArguments(bundle);
dg_connection_error.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
......
......@@ -36,6 +36,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.EventDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.HintAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
......@@ -45,6 +46,7 @@ import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.SchedulingPresenter;
import br.ufpr.c3sl.agendador.agendador.views.SchedulingView;
/**
* Created by Lucas B. Cunha on 12/4/17.
*/
......@@ -73,7 +75,8 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private HashSet<CalendarDay> hash;
//TODO: create class "ConfirmationDialog"
private ConnectionErrorDialog connectionErrorDialog;
private ConfirmationDialog confirmationDialog;
private String[] months_short;
......@@ -382,6 +385,20 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
}
public void setNoConnection(boolean enabled){
if(enabled){
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE_KEY, getString(R.string.dialog_connection_error_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
finish();
}
}
public static class ConfirmationDialog extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
......
......@@ -101,10 +101,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
@Override
public void onFailure(Call<List<UserOutput>> call, Throwable t) {
// TODO: 01/06/17 Warn user about connection failure
Log.d("Server response", getClass().getName() + ": Requisição falhou!!");
Toast.makeText(context,"Ocorreu um problema ao carregar essa página.", Toast.LENGTH_SHORT).show();
//schedulingPresenter.view().setNoConnection(true);
schedulingPresenter.view().setNoConnection(true);
schedulingPresenter.view().setProgressBar(false);
}
});
......
......@@ -16,7 +16,8 @@ public interface SchedulingView {
void successfulDependents(List<UserOutput> dependents);
void finish();
void setNoConnection(boolean enabled);
void finish();
}
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
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