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

Merge fix

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent a0f9df02
......@@ -19,6 +19,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.CitizensArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.listeners.RecyclerViewItemListener;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.CitizensPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
......
......@@ -157,7 +157,7 @@ public class ScheduleConfirmationActivity extends AppCompatActivity implements S
tv_sector.setText(sectorName);
tv_citizen.setText(citizen.getmName());
tv_citizen.setText(citizen.getName());
tv_location.setText(locationName);
tv_type.setText(typeName);
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy - HH:mm", Locale.getDefault());
......
......@@ -183,7 +183,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
TextView tv_citizen = (TextView) findViewById(R.id.tv_scheduling_citizen);
tv_citizen.setText(getResources().getString(R.string.scheduling_citizen) + " " + citizen.getmName());
tv_citizen.setText(getResources().getString(R.string.scheduling_citizen) + " " + citizen.getName());
spnr_sector = (Spinner) findViewById(R.id.spnr_scheduling_sector);
......
......@@ -23,11 +23,10 @@ import java.util.ArrayList;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.SectorArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.SectorArrayAdapter;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.presenters.TermPresenter;
import br.ufpr.c3sl.agendador.agendador.views.TermView;
......
......@@ -42,8 +42,8 @@ public class CitizensArrayAdapter extends RecyclerView.Adapter {
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
CitizenHolder citizenHolder = (CitizenHolder) holder;
UserOutput citizen = citizens.get(position);
citizenHolder.name.setText(citizen.getmName());
CitizenCompact citizen = citizens.get(position);
citizenHolder.name.setText(citizen.getName());
}
/**
......
package br.ufpr.c3sl.agendador.agendador.models;
import com.google.gson.annotations.SerializedName;
/**
* Created by lbc16 on 19/09/17.
*/
public class ScheduleNote {
private Schedule schedule;
public ScheduleNote(String note) {
this.schedule = new Schedule(note);
}
private class Schedule{
@SerializedName("note")
String note;
private Schedule(String note) {
this.note = note;
}
}
}
......@@ -7,14 +7,17 @@ import br.ufpr.c3sl.agendador.agendador.models.AccountOutput;
import br.ufpr.c3sl.agendador.agendador.models.AccountUpdate;
import br.ufpr.c3sl.agendador.agendador.models.Address;
import br.ufpr.c3sl.agendador.agendador.models.CepInput;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.Dependent;
import br.ufpr.c3sl.agendador.agendador.models.DependentCreation;
import br.ufpr.c3sl.agendador.agendador.models.FullDependent;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleConfirmation;
import br.ufpr.c3sl.agendador.agendador.models.ScheduleNote;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation;
import br.ufpr.c3sl.agendador.agendador.models.ServiceType;
import br.ufpr.c3sl.agendador.agendador.models.User;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
......@@ -49,8 +52,8 @@ public interface ApiEndpoints {
@GET("accounts/self")
Call<AccountOutput> requestSelf();
@GET("citizens?permission=citizen")
Call<List<UserOutput>> requestDependentsScheduling();
@GET("citizens/{citizen_id}/schedule_options?permission=citizen")
Call<List<CitizenCompact>> requestScheduleOptions(@Path("citizen_id") long citizenId);
@GET("sectors?permission=citizen&schedule=true")
Call<List<SectorInput>> requestSectors(@Query("citizen_id") long citizenId);
......@@ -62,7 +65,7 @@ public interface ApiEndpoints {
Call<List<ServiceLocation>> requestServicePlaces(@Query("service_type_id") long typeId, @Query("schedule") boolean needSchedule);
@PUT("schedules/{id_schedule}/confirm?permission=citizen")
Call<ScheduleConfirmation> requestPerformScheduling(@Path("id_schedule") long scheduleId, @Query("citizen_id") long citizenId);
Call<ScheduleConfirmation> requestPerformScheduling(@Path("id_schedule") long scheduleId, @Query("citizen_id") long citizenId, @Body ScheduleNote note);
@GET("schedules/{id_schedule}/confirmation?permission=citizen")
Call<ScheduleConfirmation> requestConfirmSchedule(@Path("id_schedule") long scheduleId, @Query("citizen_id") long citizenId);
......
......@@ -33,7 +33,6 @@ import retrofit2.Response;
public class AccountPresenter extends BasePresenter<AccountView> {
private Context context;
private AccountPresenter accountPresenter;
private boolean isPicUpdate;
......
package br.ufpr.c3sl.agendador.agendador.presenters;
import android.content.Context;
import android.support.annotation.NonNull;
import java.lang.ref.WeakReference;
......@@ -17,6 +18,8 @@ public abstract class BasePresenter<V> {
protected ObscuredSharedPreferences osb;
protected Context context;
protected void resetState() {
}
......@@ -46,6 +49,9 @@ public abstract class BasePresenter<V> {
}
protected void updateHeaders(Headers headers) {
if(osb == null && context != null)
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);;
if(headers.get(Utils.ACCESS_TOKEN) != null)
osb.edit().putString(Utils.ACCESS_TOKEN, headers.get(Utils.ACCESS_TOKEN)).apply();
if(headers.get(Utils.CLIENT) != null)
......
......@@ -10,8 +10,6 @@ import br.ufpr.c3sl.agendador.agendador.views.CepNotFoundView;
public class CepNotFoundPresenter extends BasePresenter<CepNotFoundView> {
Context context;
public CepNotFoundPresenter(Context context) {
this.context = context;
}
......
......@@ -28,7 +28,6 @@ import retrofit2.Response;
public class CepPresenter extends BasePresenter<CepView> {
private Context context;
private CepPresenter cepPresenter;
public CepPresenter(Context context) {
......
......@@ -10,6 +10,7 @@ import java.util.Map;
import br.ufpr.c3sl.agendador.agendador.CitizenActivity;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.CitizenCompact;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.network.ApiEndpoints;
import br.ufpr.c3sl.agendador.agendador.network.ApiUtils;
......@@ -29,6 +30,7 @@ public class CitizensPresenter extends BasePresenter<CitizenActivity> {
public CitizensPresenter(Context context){
citizensPresenter = this;
this.context = context;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
}
......@@ -45,7 +47,7 @@ public class CitizensPresenter extends BasePresenter<CitizenActivity> {
header.put(Utils.UID, osb.getString(Utils.UID, null));
final ApiEndpoints service = ApiUtils.request(header);
Call<List<UserOutput>> listCall = service.requestDependentsScheduling();
Call<List<CitizenCompact>> listCall = service.requestScheduleOptions(osb.getLong("id", 0));
citizensPresenter.view().setProgressBar(true);
listCall.enqueue(new Callback<List<CitizenCompact>>() {
......@@ -54,7 +56,7 @@ public class CitizensPresenter extends BasePresenter<CitizenActivity> {
public void onResponse(Call<List<CitizenCompact>> call, Response<List<CitizenCompact>> response) {
Headers headers = response.headers();
int status = response.code();
List<UserOutput> citizens = response.body();
List<CitizenCompact> citizens = response.body();
updateHeaders(headers);
switch (status) {
case 200:
......
......@@ -35,6 +35,7 @@ public class DependentUpdatePresenter extends BasePresenter<DependentUpdateActiv
public DependentUpdatePresenter(Context context){
presenter = this;
this.context = context;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
}
......
......@@ -45,6 +45,7 @@ public class DependentsListPresenter extends BasePresenter<DependentsListActivit
public DependentsListPresenter(Context context){
presenter = this;
this.context = context;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
}
......
......@@ -9,7 +9,7 @@ import br.ufpr.c3sl.agendador.agendador.views.HomeView;
*/
public class ForgotPasswordPresenter extends BasePresenter<HomeView> {
private Context context;
public ForgotPasswordPresenter(Context context) {
this.context = context;
......
......@@ -26,7 +26,6 @@ import retrofit2.Response;
*/
public class HomePresenter extends BasePresenter<HomeView> {
private Context context;
private HomePresenter homePresenter;
......
......@@ -48,7 +48,6 @@ import retrofit2.Response;
public class LoginPresenter extends BasePresenter<LoginView> {
private Context context;
private LoginPresenter loginPresenter;
private FirebaseJobDispatcher dispatcher;
......
......@@ -15,7 +15,6 @@ import br.ufpr.c3sl.agendador.agendador.views.MainView;
public class MainPresenter extends BasePresenter<MainView>{
private boolean isLoadingData = false;
private Context context;
public MainPresenter(Context context) {
this.context = context;
......
......@@ -33,10 +33,9 @@ public class NewDependentPresenter extends BasePresenter<NewDependentActivity> {
private NewDependentPresenter presenter;
public NewDependentPresenter(Context context){
presenter = this;
this.context = context;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
}
......
......@@ -16,6 +16,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
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.ScheduleNote;
import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
import br.ufpr.c3sl.agendador.agendador.network.ApiEndpoints;
import br.ufpr.c3sl.agendador.agendador.network.ApiUtils;
......@@ -30,8 +31,6 @@ import retrofit2.Response;
public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirmationActivity> {
private Context context;
private ScheduleConfirmationPresenter scheduleConfirmationPresenter;
public ScheduleConfirmationPresenter(Context context){
......@@ -52,7 +51,7 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm
context.startActivity(intent);
}
public void onScheduleClicked(final ScheduleConfirmation scheduleConfirmation, UserOutput citizen){
public void onScheduleClicked(final ScheduleConfirmation scheduleConfirmation, CitizenCompact citizen){
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json");
header.put(Utils.ACCESS_TOKEN, osb.getString(Utils.ACCESS_TOKEN, null));
......@@ -61,7 +60,9 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm
final ApiEndpoints service = ApiUtils.request(header);
Call<ScheduleConfirmation> listCall = service.requestPerformScheduling(scheduleConfirmation.getId(), citizen.getId());
ScheduleNote note = new ScheduleNote("");
Call<ScheduleConfirmation> listCall = service.requestPerformScheduling(scheduleConfirmation.getId(), citizen.getId(), note);
scheduleConfirmationPresenter.view().setProgressBar(true);
listCall.enqueue(new Callback<ScheduleConfirmation>() {
......
......@@ -17,6 +17,7 @@ import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
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.ScheduleNote;
import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation;
import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule;
import br.ufpr.c3sl.agendador.agendador.models.ServiceType;
......@@ -35,9 +36,6 @@ import retrofit2.Response;
public class SchedulingPresenter extends BasePresenter<SchedulingView> {
private Context context;
private SchedulingPresenter schedulingPresenter;
public SchedulingPresenter(Context context){
......@@ -118,6 +116,8 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
final ApiEndpoints service = ApiUtils.request(header);
Call<ScheduleConfirmation> listCall = service.requestConfirmSchedule(schedule.getmId(), citizen.getId());
schedulingPresenter.view().setProgressBar(true, SchedulingActivity.SHOW_PB);
......
......@@ -25,7 +25,6 @@ import retrofit2.Response;
public class SignUpPresenter extends BasePresenter<SignupView> {
private Context context;
private SignUpPresenter signUpPresenter;
public SignUpPresenter(Context context) {
......
......@@ -10,6 +10,7 @@ import java.util.Map;
import br.ufpr.c3sl.agendador.agendador.TermActivity;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
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.UserOutput;
import br.ufpr.c3sl.agendador.agendador.network.ApiEndpoints;
......@@ -25,8 +26,6 @@ import retrofit2.Response;
public class TermPresenter extends BasePresenter<TermActivity>{
private Context context;
private TermPresenter termPresenter;
private ObscuredSharedPreferences osb;
......@@ -44,7 +43,6 @@ public class TermPresenter extends BasePresenter<TermActivity>{
public void requestSectors(CitizenCompact citizen){
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json");
header.put(Utils.ACCESS_TOKEN, osb.getString(Utils.ACCESS_TOKEN, null));
......
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