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
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;
......@@ -137,7 +137,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
private static final String SCHEDULES_TIME_ARRAY = "schedules_time_array";
// TODO: 03/08/17 bug em que o calendario não é pintado
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -405,7 +404,7 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
else{
spnr_type.setEnabled(true);
}
if(flag == SECTOR_SElECTED){
if(flag == SECTOR_SELECTED){
spnr_location.setEnabled(false);
spnr_location.setSelection(hintAdapterLocation.getCount());
}
......@@ -489,7 +488,6 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
locationSpinnerListener.setUserSelect(false);
serviceTypeSpinnerListener.setUserSelect(false);
sectorSpinnerListener.setUserSelect(false);
List<ServiceType> serviceTypes1 = serviceTypes;
serviceTypeSpinnerListener.setServiceTypes(serviceTypes);
spnr_type.setEnabled(true);
......@@ -518,9 +516,25 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
int max = 0;
boolean hasCreatedDecorator1 = false;
boolean hasCreatedDecorator2 = false;
String[] locations;
boolean[] paintViewLocation;
locationSpinnerListener.setUserSelect(false);
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){
if(location.getmPeriod() > max)
......@@ -533,29 +547,29 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE));
mcv.state().edit().setMaximumDate(cal).commit();
String[] locations;
boolean[] paintViewLocation;
if(serviceLocations.size() > 0) {
locations = new String[serviceLocations.size() + 1];
paintViewLocation = new boolean[serviceLocations.size() + 1];
for (i = 0; i < serviceLocations.size(); i++) {
locations[i] = serviceLocations.get(i).getmName() + " (" + serviceLocations.get(i).getSchedules().size() + ")";
String name;
locations = new String[serviceLocations.size() + 1];
paintViewLocation = new boolean[serviceLocations.size() + 1];
for (i = 0; i < serviceLocations.size(); i++) {
name = serviceLocations.get(i).getmName();
if(name.length() > 33) {
name = name.substring(0, 33);
name = name.trim();
name = name + "...";
}
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;
}
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);
spnr_location.setAdapter(hintAdapterLocation);
locationSpinnerListener.setUserSelect(false);
......@@ -566,17 +580,19 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
for( ServiceLocation sl : serviceLocations){
HashMap<String, ArrayList<ServiceSchedule>> hashMap = new HashMap<>();
for (ServiceSchedule schedule : sl.getSchedules()){
String date = dateFormat.format(schedule.getStart());
if(hashMap.containsKey(date)){
hashMap.get(date).add(schedule);
}else{
ArrayList<ServiceSchedule> list = new ArrayList<>();
list.add(schedule);
hashMap.put(date, list);
if(sl.getSchedules() != null) {
for (ServiceSchedule schedule : sl.getSchedules()) {
String date = dateFormat.format(schedule.getStart());
if (hashMap.containsKey(date)) {
hashMap.get(date).add(schedule);
} else {
ArrayList<ServiceSchedule> list = new ArrayList<>();
list.add(schedule);
hashMap.put(date, list);
}
}
listOfScheduleDays.add(hashMap);
}
listOfScheduleDays.add(hashMap);
}
......@@ -713,5 +729,4 @@ public class SchedulingActivity extends AppCompatActivity implements SchedulingV
}
......@@ -45,14 +45,6 @@ public class Utils {
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) {
Resources resources = context.getResources();
......
......@@ -65,7 +65,7 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm
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){
Map<String, String> header = new HashMap<>();
header.put("Content-Type", "application/json");
......@@ -84,13 +84,13 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm
public void onResponse(Call<ScheduleConfirmation> call, Response<ScheduleConfirmation> response) {
Headers headers = response.headers();
int status = response.code();
ScheduleConfirmation confirmation = response.body();
ScheduleConfirmation confirmationResponse = response.body();
switch (status) {
case 200:
Log.d("Server response", this.getClass().getName() + ": 200 - Sucesso!");
updateToken(headers);
scheduleConfirmationPresenter.view().setProgressBar(false);
scheduleConfirmationPresenter.view().onSuccess();
break;
default:
......
......@@ -3,17 +3,12 @@ package br.ufpr.c3sl.agendador.agendador.presenters;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
import com.firebase.jobdispatcher.FirebaseJobDispatcher;
import com.firebase.jobdispatcher.GooglePlayDriver;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import br.ufpr.c3sl.agendador.agendador.LoginActivity;
......@@ -102,7 +97,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
case 200:
Log.d("Server response", getClass().getName() + ": 200 - Sucesso!");
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;
default:
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