Commit e7fe7333 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha
Browse files

Merge branch 'develop' into 'list_update_dependents'

# Conflicts:
#   app/src/main/java/br/ufpr/c3sl/agendador/agendador/CitizenActivity.java
#   app/src/main/java/br/ufpr/c3sl/agendador/agendador/helpers/adapters/CitizensArrayAdapter.java
#   app/src/main/java/br/ufpr/c3sl/agendador/agendador/network/ApiEndpoints.java
#   app/src/main/java/br/ufpr/c3sl/agendador/agendador/network/ApiUtils.java
#   app/src/main/java/br/ufpr/c3sl/agendador/agendador/presenters/CitizensPresenter.java
#   app/src/main/java/br/ufpr/c3sl/agendador/agendador/presenters/ScheduleConfirmationPresenter.java
#   app/src/main/java/br/ufpr/c3sl/agendador/agendador/presenters/TermPresenter.java
parents 806a83cf 64c6218e
...@@ -38,7 +38,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{ ...@@ -38,7 +38,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
private CitizensPresenter citizensPresenter; private CitizensPresenter citizensPresenter;
private List<UserOutput> citizens; private List<CitizenCompact> citizens;
private ConnectionFailureDialog dg_connection_failure; private ConnectionFailureDialog dg_connection_failure;
...@@ -117,7 +117,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{ ...@@ -117,7 +117,7 @@ public class CitizenActivity extends AppCompatActivity implements CitizenView{
} }
} }
public void successfulCitizens(List<UserOutput> citizens) { public void successfulCitizens(List<CitizenCompact> citizens) {
this.citizens = citizens; this.citizens = citizens;
} }
......
...@@ -32,6 +32,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog; ...@@ -32,6 +32,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences; import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper; import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils; import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation; import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput; import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager; import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
...@@ -76,7 +77,7 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S ...@@ -76,7 +77,7 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
setContentView(R.layout.activity_schedule_confirmation); setContentView(R.layout.activity_schedule_confirmation);
Bundle bundle = getIntent().getBundleExtra(Utils.SCHEDULE_BUNDLE); Bundle bundle = getIntent().getBundleExtra(Utils.SCHEDULE_BUNDLE);
final UserOutput citizen = bundle.getParcelable(Utils.CITIZEN); final CitizenCompact citizen = bundle.getParcelable(Utils.CITIZEN);
final ScheduleConfirmation scheduleConfirmation = bundle.getParcelable(Utils.SCHEDULE_CONFIRMATION); final ScheduleConfirmation scheduleConfirmation = bundle.getParcelable(Utils.SCHEDULE_CONFIRMATION);
String sectorName = scheduleConfirmation.getSectorName(); String sectorName = scheduleConfirmation.getSectorName();
String locationName = scheduleConfirmation.getLocationName(); String locationName = scheduleConfirmation.getLocationName();
......
...@@ -50,6 +50,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.decorators.SchedulesDecorator; ...@@ -50,6 +50,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.decorators.SchedulesDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.listeners.LocationSpinnerListener; import br.ufpr.c3sl.agendador.agendador.helpers.listeners.LocationSpinnerListener;
import br.ufpr.c3sl.agendador.agendador.helpers.listeners.SectorSpinnerListener; import br.ufpr.c3sl.agendador.agendador.helpers.listeners.SectorSpinnerListener;
import br.ufpr.c3sl.agendador.agendador.helpers.listeners.ServiceTypeSpinnerListener; import br.ufpr.c3sl.agendador.agendador.helpers.listeners.ServiceTypeSpinnerListener;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation; import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput; import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation; import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation;
...@@ -91,7 +92,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -91,7 +92,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private SchedulingPresenter presenter; private SchedulingPresenter presenter;
private UserOutput citizen; private CitizenCompact citizen;
private ServiceTypeSpinnerListener serviceTypeSpinnerListener; private ServiceTypeSpinnerListener serviceTypeSpinnerListener;
......
...@@ -25,6 +25,7 @@ import java.util.List; ...@@ -25,6 +25,7 @@ import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog; import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.SectorArrayAdapter; import br.ufpr.c3sl.agendador.agendador.helpers.adapters.SectorArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils; import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput; import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput; import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager; import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
...@@ -45,7 +46,7 @@ public class TermActivity extends AppCompatActivity implements TermView { ...@@ -45,7 +46,7 @@ public class TermActivity extends AppCompatActivity implements TermView {
private ConnectionFailureDialog dg_connection_failure; private ConnectionFailureDialog dg_connection_failure;
private UserOutput citizen; private CitizenCompact citizen;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
......
...@@ -9,6 +9,7 @@ import android.view.ViewGroup; ...@@ -9,6 +9,7 @@ import android.view.ViewGroup;
import java.util.List; import java.util.List;
import br.ufpr.c3sl.agendador.agendador.R; import br.ufpr.c3sl.agendador.agendador.R;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput; import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
...@@ -19,11 +20,11 @@ import br.ufpr.c3sl.agendador.agendador.models.UserOutput; ...@@ -19,11 +20,11 @@ import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
public class CitizensArrayAdapter extends RecyclerView.Adapter { public class CitizensArrayAdapter extends RecyclerView.Adapter {
private List<UserOutput> citizens; private List<CitizenCompact> citizens;
private Context context; private Context context;
public CitizensArrayAdapter(Context context, List<UserOutput> citizens){ public CitizensArrayAdapter(Context context, List<CitizenCompact> citizens){
super(); super();
this.citizens = citizens; this.citizens = citizens;
this.context = context; this.context = context;
......
package br.ufpr.c3sl.agendador.agendador.models;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.SerializedName;
/**
* Created by Lucas Braz Cunha on 10/08/17.
*/
public class CitizenCompact implements Parcelable{
@SerializedName("id")
private long id;
@SerializedName("name")
private String name;
@SerializedName("birth_date")
private String birthDate;
@SerializedName("rg")
private String rg;
@SerializedName("cpf")
private String cpf;
public CitizenCompact(long id, String name, String birth_Date, String rg, String cpf) {
this.id = id;
this.name = name;
this.birthDate = birth_Date;
this.rg = rg;
this.cpf = cpf;
}
/** Static field used to regenerate object, individually or as arrays */
public static final Parcelable.Creator<CitizenCompact> CREATOR = new Parcelable.Creator<CitizenCompact>() {
public CitizenCompact createFromParcel(Parcel pc) {
return new CitizenCompact(pc);
}
public CitizenCompact[] newArray(int size) {
return new CitizenCompact[size];
}
};
/**reads back fields IN THE ORDER they were written */
private CitizenCompact(Parcel pc){
id = pc.readLong();
name = pc.readString();
birthDate = pc.readString();
rg = pc.readString();
cpf = pc.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(name);
dest.writeString(birthDate);
dest.writeString(rg);
dest.writeString(cpf);
}
@Override
public int describeContents() {
return 0;
}
public long getId() {
return id;
}
public String getName() {
return name;
}
}
...@@ -11,13 +11,13 @@ import com.google.gson.annotations.SerializedName; ...@@ -11,13 +11,13 @@ import com.google.gson.annotations.SerializedName;
public class City implements Parcelable{ public class City implements Parcelable{
//package private because they're used on UserOutput.
@SerializedName("id") @SerializedName("id")
private long mId; private long mId;
@SerializedName("ibge_code") @SerializedName("ibge_code")
private int mIbge_code; private int mIbge_code;
//package private because they're used on UserOutput.
@SerializedName("name") @SerializedName("name")
String mName; String mName;
......
...@@ -13,15 +13,11 @@ import br.ufpr.c3sl.agendador.agendador.models.FullDependent; ...@@ -13,15 +13,11 @@ import br.ufpr.c3sl.agendador.agendador.models.FullDependent;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation; import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput; import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation; import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation;
import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule;
import br.ufpr.c3sl.agendador.agendador.models.ServiceType; import br.ufpr.c3sl.agendador.agendador.models.ServiceType;
import br.ufpr.c3sl.agendador.agendador.models.SignOutOutput;
import br.ufpr.c3sl.agendador.agendador.models.User; import br.ufpr.c3sl.agendador.agendador.models.User;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.PATCH; import retrofit2.http.PATCH;
import retrofit2.http.POST; import retrofit2.http.POST;
......
...@@ -48,10 +48,10 @@ public class CitizensPresenter extends BasePresenter<CitizenActivity> { ...@@ -48,10 +48,10 @@ public class CitizensPresenter extends BasePresenter<CitizenActivity> {
Call<List<UserOutput>> listCall = service.requestDependentsScheduling(); Call<List<UserOutput>> listCall = service.requestDependentsScheduling();
citizensPresenter.view().setProgressBar(true); citizensPresenter.view().setProgressBar(true);
listCall.enqueue(new Callback<List<UserOutput>>() { listCall.enqueue(new Callback<List<CitizenCompact>>() {
@Override @Override
public void onResponse(Call<List<UserOutput>> call, Response<List<UserOutput>> response) { public void onResponse(Call<List<CitizenCompact>> call, Response<List<CitizenCompact>> response) {
Headers headers = response.headers(); Headers headers = response.headers();
int status = response.code(); int status = response.code();
List<UserOutput> citizens = response.body(); List<UserOutput> citizens = response.body();
...@@ -73,7 +73,7 @@ public class CitizensPresenter extends BasePresenter<CitizenActivity> { ...@@ -73,7 +73,7 @@ public class CitizensPresenter extends BasePresenter<CitizenActivity> {
} }
@Override @Override
public void onFailure(Call<List<UserOutput>> call, Throwable t) { public void onFailure(Call<List<CitizenCompact>> call, Throwable t) {
Log.e("Server response", getClass().getName() + ": Requisição falhou!!"); Log.e("Server response", getClass().getName() + ": Requisição falhou!!");
citizensPresenter.view().setProgressBar(false); citizensPresenter.view().setProgressBar(false);
citizensPresenter.view().onRequestFailure(); citizensPresenter.view().onRequestFailure();
......
...@@ -14,6 +14,7 @@ import br.ufpr.c3sl.agendador.agendador.LoginActivity; ...@@ -14,6 +14,7 @@ import br.ufpr.c3sl.agendador.agendador.LoginActivity;
import br.ufpr.c3sl.agendador.agendador.ScheduleConfirmationActivity; import br.ufpr.c3sl.agendador.agendador.ScheduleConfirmationActivity;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences; import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils; import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation; import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput; import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.network.ApiEndpoints; import br.ufpr.c3sl.agendador.agendador.network.ApiEndpoints;
...@@ -60,7 +61,7 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm ...@@ -60,7 +61,7 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm
final ApiEndpoints service = ApiUtils.request(header); final ApiEndpoints service = ApiUtils.request(header);
Call<ScheduleConfirmation> listCall = service.requestPerformScheduling(scheduleConfirmation.getId(), citizen.getmId()); Call<ScheduleConfirmation> listCall = service.requestPerformScheduling(scheduleConfirmation.getId(), citizen.getId());
scheduleConfirmationPresenter.view().setProgressBar(true); scheduleConfirmationPresenter.view().setProgressBar(true);
listCall.enqueue(new Callback<ScheduleConfirmation>() { listCall.enqueue(new Callback<ScheduleConfirmation>() {
......
...@@ -15,6 +15,7 @@ import br.ufpr.c3sl.agendador.agendador.LoginActivity; ...@@ -15,6 +15,7 @@ import br.ufpr.c3sl.agendador.agendador.LoginActivity;
import br.ufpr.c3sl.agendador.agendador.SchedulingActivity; import br.ufpr.c3sl.agendador.agendador.SchedulingActivity;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences; import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils; import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation; import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation; import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation;
import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule; import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule;
...@@ -108,7 +109,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> { ...@@ -108,7 +109,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
} }
public void onScheduleButtonClicked(final ServiceSchedule schedule, final UserOutput citizen){ public void onScheduleButtonClicked(final ServiceSchedule schedule, final CitizenCompact citizen){
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json"); header.put("Content-Type", "application/json");
header.put(Utils.ACCESS_TOKEN, osb.getString(Utils.ACCESS_TOKEN, null)); header.put(Utils.ACCESS_TOKEN, osb.getString(Utils.ACCESS_TOKEN, null));
...@@ -117,7 +118,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> { ...@@ -117,7 +118,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
final ApiEndpoints service = ApiUtils.request(header); final ApiEndpoints service = ApiUtils.request(header);
Call<ScheduleConfirmation> listCall = service.requestConfirmSchedule(schedule.getmId(), citizen.getmId()); Call<ScheduleConfirmation> listCall = service.requestConfirmSchedule(schedule.getmId(), citizen.getId());
schedulingPresenter.view().setProgressBar(true, SchedulingActivity.SHOW_PB); schedulingPresenter.view().setProgressBar(true, SchedulingActivity.SHOW_PB);
listCall.enqueue(new Callback<ScheduleConfirmation>() { listCall.enqueue(new Callback<ScheduleConfirmation>() {
......
...@@ -43,7 +43,7 @@ public class TermPresenter extends BasePresenter<TermActivity>{ ...@@ -43,7 +43,7 @@ public class TermPresenter extends BasePresenter<TermActivity>{
} }
public void requestSectors(UserOutput citizen){ public void requestSectors(CitizenCompact citizen){
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json"); header.put("Content-Type", "application/json");
...@@ -52,7 +52,7 @@ public class TermPresenter extends BasePresenter<TermActivity>{ ...@@ -52,7 +52,7 @@ public class TermPresenter extends BasePresenter<TermActivity>{
header.put(Utils.UID, osb.getString(Utils.UID, null)); header.put(Utils.UID, osb.getString(Utils.UID, null));
final ApiEndpoints service = ApiUtils.request(header); final ApiEndpoints service = ApiUtils.request(header);
Call<List<SectorInput>> listCall = service.requestSectors(citizen.getmId()); Call<List<SectorInput>> listCall = service.requestSectors(citizen.getId());
termPresenter.view().setProgressBar(true); termPresenter.view().setProgressBar(true);
listCall.enqueue(new Callback<List<SectorInput>>() { listCall.enqueue(new Callback<List<SectorInput>>() {
......
...@@ -6,7 +6,6 @@ package br.ufpr.c3sl.agendador.agendador.views; ...@@ -6,7 +6,6 @@ package br.ufpr.c3sl.agendador.agendador.views;
public interface CitizenView { public interface CitizenView {
void showLayout(boolean enabled); void showLayout(boolean enabled);
void setProgressBar(boolean enabled); void setProgressBar(boolean enabled);
......
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