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

Issue AGILE#198 Bug fix

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent 5d8e4a51
...@@ -118,7 +118,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -118,7 +118,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
public static final int NO_AVAILABLE_LOCATION = 0x10; public static final int NO_AVAILABLE_LOCATION = 0x10;
public static final int SECTOR_SElECTED = 0x11; public static final int SECTOR_SELECTED = 0x11;
public static final int TYPE_SELECTED = 0x12; public static final int TYPE_SELECTED = 0x12;
...@@ -137,7 +137,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -137,7 +137,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private static final String SCHEDULES_TIME_ARRAY = "schedules_time_array"; private static final String SCHEDULES_TIME_ARRAY = "schedules_time_array";
// TODO: 03/08/17 bug em que o calendario não é pintado
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -405,7 +404,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -405,7 +404,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
else{ else{
spnr_type.setEnabled(true); spnr_type.setEnabled(true);
} }
if(flag == SECTOR_SElECTED){ if(flag == SECTOR_SELECTED){
spnr_location.setEnabled(false); spnr_location.setEnabled(false);
spnr_location.setSelection(hintAdapterLocation.getCount()); spnr_location.setSelection(hintAdapterLocation.getCount());
} }
...@@ -489,7 +488,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -489,7 +488,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
locationSpinnerListener.setUserSelect(false); locationSpinnerListener.setUserSelect(false);
serviceTypeSpinnerListener.setUserSelect(false); serviceTypeSpinnerListener.setUserSelect(false);
sectorSpinnerListener.setUserSelect(false); sectorSpinnerListener.setUserSelect(false);
List<ServiceType> serviceTypes1 = serviceTypes;
serviceTypeSpinnerListener.setServiceTypes(serviceTypes); serviceTypeSpinnerListener.setServiceTypes(serviceTypes);
spnr_type.setEnabled(true); spnr_type.setEnabled(true);
...@@ -518,9 +516,25 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -518,9 +516,25 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
int max = 0; int max = 0;
boolean hasCreatedDecorator1 = false; boolean hasCreatedDecorator1 = false;
boolean hasCreatedDecorator2 = false; boolean hasCreatedDecorator2 = false;
String[] locations;
boolean[] paintViewLocation;
locationSpinnerListener.setUserSelect(false); locationSpinnerListener.setUserSelect(false);
locationSpinnerListener.setServiceLocations(serviceLocations); locationSpinnerListener.setServiceLocations(serviceLocations);
List<ServiceLocation> serviceLocations1 = serviceLocations;
if(serviceLocations == null || serviceLocations.size() == 0){
locations = new String[2];
paintViewLocation = new boolean[2];
locations[1] = getResources().getString(R.string.no_available_hint);
locations[0] = getResources().getString(R.string.no_available_hint);
paintViewLocation[1] = false;
paintViewLocation[0] = true;
hintAdapterLocation = new HintEnableAdapter(this, android.R.layout.simple_list_item_1, locations, paintViewLocation, Color.BLACK);
spnr_location.setAdapter(hintAdapterLocation);
locationSpinnerListener.setUserSelect(false);
spnr_location.setSelection(hintAdapterLocation.getCount());
return;
}
for(ServiceLocation location : serviceLocations){ for(ServiceLocation location : serviceLocations){
if(location.getmPeriod() > max) if(location.getmPeriod() > max)
...@@ -533,29 +547,29 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -533,29 +547,29 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE));
mcv.state().edit().setMaximumDate(cal).commit(); mcv.state().edit().setMaximumDate(cal).commit();
String name;
locations = new String[serviceLocations.size() + 1];
String[] locations; paintViewLocation = new boolean[serviceLocations.size() + 1];
boolean[] paintViewLocation; for (i = 0; i < serviceLocations.size(); i++) {
name = serviceLocations.get(i).getmName();
if(serviceLocations.size() > 0) { if(name.length() > 33) {
locations = new String[serviceLocations.size() + 1]; name = name.substring(0, 33);
paintViewLocation = new boolean[serviceLocations.size() + 1]; name = name.trim();
for (i = 0; i < serviceLocations.size(); i++) { name = name + "...";
locations[i] = serviceLocations.get(i).getmName() + " (" + serviceLocations.get(i).getSchedules().size() + ")"; }
if(serviceLocations.get(i).getSchedules() == null) {
locations[i] = name + " (0)";
paintViewLocation[i] = true;
}
else{
locations[i] = name + " (" + serviceLocations.get(i).getSchedules().size() + ")";
paintViewLocation[i] = serviceLocations.get(i).getSchedules().size() == 0; paintViewLocation[i] = serviceLocations.get(i).getSchedules().size() == 0;
} }
locations[i] = getResources().getString(R.string.scheduling_location_hint);
paintViewLocation[i] = false;
}
else{
locations = new String[2];
paintViewLocation = new boolean[2];
locations[1] = getResources().getString(R.string.no_available_hint);
locations[0] = "";
paintViewLocation[1] = false;
paintViewLocation[0] = false;
} }
locations[i] = getResources().getString(R.string.scheduling_location_hint);
paintViewLocation[i] = false;
hintAdapterLocation = new HintEnableAdapter(this, android.R.layout.simple_list_item_1, locations, paintViewLocation, Color.GRAY); hintAdapterLocation = new HintEnableAdapter(this, android.R.layout.simple_list_item_1, locations, paintViewLocation, Color.GRAY);
spnr_location.setAdapter(hintAdapterLocation); spnr_location.setAdapter(hintAdapterLocation);
locationSpinnerListener.setUserSelect(false); locationSpinnerListener.setUserSelect(false);
...@@ -566,17 +580,19 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -566,17 +580,19 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
for( ServiceLocation sl : serviceLocations){ for( ServiceLocation sl : serviceLocations){
HashMap<String, ArrayList<ServiceSchedule>> hashMap = new HashMap<>(); HashMap<String, ArrayList<ServiceSchedule>> hashMap = new HashMap<>();
for (ServiceSchedule schedule : sl.getSchedules()){ if(sl.getSchedules() != null) {
String date = dateFormat.format(schedule.getStart()); for (ServiceSchedule schedule : sl.getSchedules()) {
if(hashMap.containsKey(date)){ String date = dateFormat.format(schedule.getStart());
hashMap.get(date).add(schedule); if (hashMap.containsKey(date)) {
}else{ hashMap.get(date).add(schedule);
ArrayList<ServiceSchedule> list = new ArrayList<>(); } else {
list.add(schedule); ArrayList<ServiceSchedule> list = new ArrayList<>();
hashMap.put(date, list); list.add(schedule);
hashMap.put(date, list);
}
} }
listOfScheduleDays.add(hashMap);
} }
listOfScheduleDays.add(hashMap);
} }
...@@ -713,5 +729,4 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV ...@@ -713,5 +729,4 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
} }
...@@ -45,14 +45,6 @@ public class Utils { ...@@ -45,14 +45,6 @@ public class Utils {
public static final String CITIZEN_BUNDLE = "br.ufpr.c3sl.agendador.agendador.citizen_bundle"; public static final String CITIZEN_BUNDLE = "br.ufpr.c3sl.agendador.agendador.citizen_bundle";
// TODO: 31/07/17 delete if not needed (till merge)
/*
public static final String SECTOR = "selected_sector";
public static final String LOCATION = "selected_location";
public static final String TYPE = "selected_type";
*/
public static int getPixelValue(int dp, Context context) { public static int getPixelValue(int dp, Context context) {
Resources resources = context.getResources(); Resources resources = context.getResources();
......
...@@ -65,7 +65,7 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm ...@@ -65,7 +65,7 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm
context.startActivity(intent); context.startActivity(intent);
} }
// TODO: 31/07/17 Check if the received id is the same as the sent one. // TODO: 31/07/17 Check if the received id is the same as the sent one - is it necessary?
public void onScheduleClicked(final ScheduleConfirmation scheduleConfirmation, UserOutput citizen){ public void onScheduleClicked(final ScheduleConfirmation scheduleConfirmation, UserOutput 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");
...@@ -84,13 +84,13 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm ...@@ -84,13 +84,13 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm
public void onResponse(Call<ScheduleConfirmation> call, Response<ScheduleConfirmation> response) { public void onResponse(Call<ScheduleConfirmation> call, Response<ScheduleConfirmation> response) {
Headers headers = response.headers(); Headers headers = response.headers();
int status = response.code(); int status = response.code();
ScheduleConfirmation confirmation = response.body(); ScheduleConfirmation confirmationResponse = response.body();
switch (status) { switch (status) {
case 200: case 200:
Log.d("Server response", this.getClass().getName() + ": 200 - Sucesso!"); Log.d("Server response", this.getClass().getName() + ": 200 - Sucesso!");
updateToken(headers); updateToken(headers);
scheduleConfirmationPresenter.view().setProgressBar(false); scheduleConfirmationPresenter.view().setProgressBar(false);
scheduleConfirmationPresenter.view().onSuccess(); scheduleConfirmationPresenter.view().onSuccess();
break; break;
default: default:
......
...@@ -3,17 +3,12 @@ package br.ufpr.c3sl.agendador.agendador.presenters; ...@@ -3,17 +3,12 @@ package br.ufpr.c3sl.agendador.agendador.presenters;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import android.util.Log;
import android.widget.Toast;
import com.firebase.jobdispatcher.FirebaseJobDispatcher; import com.firebase.jobdispatcher.FirebaseJobDispatcher;
import com.firebase.jobdispatcher.GooglePlayDriver; import com.firebase.jobdispatcher.GooglePlayDriver;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import br.ufpr.c3sl.agendador.agendador.LoginActivity; import br.ufpr.c3sl.agendador.agendador.LoginActivity;
...@@ -102,7 +97,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> { ...@@ -102,7 +97,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
case 200: case 200:
Log.d("Server response", getClass().getName() + ": 200 - Sucesso!"); Log.d("Server response", getClass().getName() + ": 200 - Sucesso!");
schedulingPresenter.view().setServiceTypesList(serviceTypes); schedulingPresenter.view().setServiceTypesList(serviceTypes);
schedulingPresenter.view().setProgressBar(false, serviceTypes.size() > 0 ? SchedulingActivity.SECTOR_SElECTED : SchedulingActivity.NO_AVAILABLE_TYPE); schedulingPresenter.view().setProgressBar(false, serviceTypes.size() > 0 ? SchedulingActivity.SECTOR_SELECTED : SchedulingActivity.NO_AVAILABLE_TYPE);
break; break;
default: default:
Log.e("Server response", getClass().getName() + ": ERRO:" + status); Log.e("Server response", getClass().getName() + ": ERRO:" + status);
......
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