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

AGILE#320: Bug fix - DependentsListActivity

Signed-off-by: Lucas Braz Cunha's avatarLucas Braz Cunha <lbc16@inf.ufpr.br>
parent efa42aca
......@@ -236,7 +236,7 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
scheduleConfirmation.getLocationName(), scheduleConfirmation.getAddressStreet(), scheduleConfirmation.getAddressNumber());
notification.reminderTime = sdfServer.format(scheduleConfirmation.getStartTime().getTime() - (reminderTimeArray[sp_notification.getSelectedItemPosition()]));
notification.reminderTime = sdfServer.format(scheduleConfirmation.getStartTime().getTime() -reminderTimeArray[sp_notification.getSelectedItemPosition()]);
if (rb_yes.isChecked()) {
notification.emailAddress = et_email.getText().toString();
......
package br.ufpr.c3sl.agendador.agendador.models;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* Created by Lucas Braz Cunha on 07/02/18.
*
* model for request: requestDependentsList
*
* path: citizens/{id_user}/dependants?permission=citizen
*/
public class RequestDependentList {
@SerializedName("num_entries")
private long numEntries;
@SerializedName("entries")
public List<Dependent> dependentsList;
}
......@@ -17,6 +17,7 @@ import br.ufpr.c3sl.agendador.agendador.models.FullDependent;
import br.ufpr.c3sl.agendador.agendador.models.Notification;
import br.ufpr.c3sl.agendador.agendador.models.NotificationReturn;
import br.ufpr.c3sl.agendador.agendador.models.NotificationUpdate;
import br.ufpr.c3sl.agendador.agendador.models.RequestDependentList;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleInfo;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleNote;
......@@ -78,7 +79,7 @@ public interface ApiEndpoints {
Call<ScheduleConfirmation> requestConfirmSchedule(@Path("id_schedule") long scheduleId, @Query("citizen_id") long citizenId);
@GET("citizens/{id_user}/dependants?permission=citizen")
Call<List<Dependent>> requestDependentsList(@Path("id_user") long citizenId);
Call<RequestDependentList> requestDependentsList(@Path("id_user") long citizenId);
@GET("citizens/{id_user}/dependants/{id_dependent}?permission=citizen")
Call<FullDependent> requestDependentInfo(@Path("id_user") long citizenId, @Path("id_dependent") long dependentId);
......
......@@ -26,6 +26,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.Dependent;
import br.ufpr.c3sl.agendador.agendador.models.FullDependent;
import br.ufpr.c3sl.agendador.agendador.models.RequestDependentList;
import br.ufpr.c3sl.agendador.agendador.network.ApiEndpoints;
import br.ufpr.c3sl.agendador.agendador.network.ApiUtils;
import br.ufpr.c3sl.agendador.agendador.services.ImageUpdateService;
......@@ -58,16 +59,17 @@ public class DependentsListPresenter extends BasePresenter<DependentsListActivit
header.put(Utils.UID, osb.getString(Utils.UID, null));
final ApiEndpoints service = ApiUtils.request(header);
Call<List<Dependent>> listCall = service.requestDependentsList(osb.getLong(Utils.ID, 0));
Call<RequestDependentList> listCall = service.requestDependentsList(osb.getLong(Utils.ID, 0));
presenter.view().setProgressBar(true);
listCall.enqueue(new Callback<List<Dependent>>() {
listCall.enqueue(new Callback<RequestDependentList>() {
@Override
public void onResponse(Call<List<Dependent>> call, Response<List<Dependent>> response) {
public void onResponse(Call<RequestDependentList> call, Response<RequestDependentList> response) {
Headers headers = response.headers();
int status = response.code();
List<Dependent> dependents = response.body();
RequestDependentList requestDependentList = response.body();
List<Dependent> dependents = requestDependentList.dependentsList;
updateHeaders(headers);
switch (status) {
case 200:
......@@ -85,8 +87,9 @@ public class DependentsListPresenter extends BasePresenter<DependentsListActivit
}
@Override
public void onFailure(Call<List<Dependent>> call, Throwable t) {
Log.e("Server response", getClass().getName() + ": Requisição falhou!!");
public void onFailure(Call<RequestDependentList> call, Throwable t) {
Log.e("Server response", getClass().getName() + ": Requisição requestDependents falhou!!");
t.printStackTrace();
presenter.view().setProgressBar(false);
presenter.view().onRequestFailure();
}
......@@ -148,7 +151,7 @@ public class DependentsListPresenter extends BasePresenter<DependentsListActivit
@Override
public void onFailure(Call<FullDependent> call, Throwable t) {
Log.e("Server response", getClass().getName() + ": Requisição falhou!!");
Log.e("Server response", getClass().getName() + ": Requisição requestDependentInfo falhou!!");
presenter.view().setProgressBar(false);
presenter.view().onRequestFailure();
}
......@@ -200,6 +203,7 @@ public class DependentsListPresenter extends BasePresenter<DependentsListActivit
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Log.e("Server response", getClass().getName() + ": Requisição requestImage falhou!!");
presenter.view().setProgressBar(false);
presenter.view().afterPictureFailed();
......
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