Commit 575575ab authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Issue AGILE#182 [WIP] added spinner behavior of disabling locations

Signed-off-by: Lucas Braz Cunha's avatarLucas B. Cunha <lbc16@inf.ufpr.br>
parent f1a07c26
......@@ -13,13 +13,11 @@ import android.widget.ArrayAdapter;
public class HintAdapter extends ArrayAdapter<String> {
public HintAdapter(Context context, int resource, String[] objects) {
super(context, resource, objects);
}
public HintAdapter(@NonNull Context context, @LayoutRes int resource) {
super(context, resource);
}
@Override
public int getCount() {
......
package br.ufpr.c3sl.agendador.agendador.helpers.adapters;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
/**
* Created by Lucas B. Cunha on 07/07/17.
*
* Thanks to Luan Dang at https://stackoverflow.com/a/24951888
*
*/
public class HintEnableAdapter extends ArrayAdapter<String> {
boolean[] enableView;
public HintEnableAdapter(Context context, int resource, String[] objects, boolean[] enableView) {
super(context, resource, objects);
this.enableView = enableView;
}
@Override
public boolean isEnabled(int position) {
return enableView[position];
}
@Override
public boolean areAllItemsEnabled() {
return false;
}
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
View mView = super.getDropDownView(position, convertView, parent);
TextView mTextView = (TextView) mView;
if (!enableView[position])
mTextView.setTextColor(Color.GRAY);
else
mTextView.setTextColor(Color.BLACK);
return mView;
}
@Override
public int getCount() {
// don't display last item. It is used as hint.
int count = super.getCount();
return count > 0 ? count - 1 : count;
}
}
package br.ufpr.c3sl.agendador.agendador.helpers;
package br.ufpr.c3sl.agendador.agendador.helpers.decorators;
import android.content.Context;
import android.support.v4.content.ContextCompat;
......@@ -21,7 +21,7 @@ import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule;
* Created by Lucas B. Cunha on 13/07/17.
*/
public class SchedulingDecorator implements DayViewDecorator {
public class NotAvailableDecorator implements DayViewDecorator {
public static int INVALID_STATE = -1;
......@@ -33,7 +33,7 @@ public class SchedulingDecorator implements DayViewDecorator {
private DateFormat dateFormat;
public SchedulingDecorator(List<HashMap<String,ArrayList<ServiceSchedule>>> listOfScheduleDays, Context context) {
public NotAvailableDecorator(List<HashMap<String,ArrayList<ServiceSchedule>>> listOfScheduleDays, Context context) {
this.listOfScheduleDays = listOfScheduleDays;
this.context = context;
dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
......@@ -47,7 +47,7 @@ public class SchedulingDecorator implements DayViewDecorator {
*/
@Override
public boolean shouldDecorate(CalendarDay day) {
return scheduleType != INVALID_STATE && !listOfScheduleDays.get(scheduleType).containsKey(dateFormat.format(day.getDate()));
return scheduleType != INVALID_STATE && !listOfScheduleDays.get(scheduleType).containsKey(dateFormat.format(day.getDate()));
}
/**
......
package br.ufpr.c3sl.agendador.agendador.helpers;
package br.ufpr.c3sl.agendador.agendador.helpers.decorators;
import android.content.Context;
import android.support.v4.content.ContextCompat;
......@@ -21,7 +21,7 @@ import br.ufpr.c3sl.agendador.agendador.models.ServiceSchedule;
* Created by Lucas B. Cunha on 25/05/17.
*/
public class EventDecorator implements DayViewDecorator {
public class SchedulesDecorator implements DayViewDecorator {
public static int INVALID_STATE = -1;
......@@ -33,7 +33,7 @@ public class EventDecorator implements DayViewDecorator {
private DateFormat dateFormat;
public EventDecorator(List<HashMap<String,ArrayList<ServiceSchedule>>> listOfScheduleDays, Context context) {
public SchedulesDecorator(List<HashMap<String,ArrayList<ServiceSchedule>>> listOfScheduleDays, Context context) {
this.listOfScheduleDays = listOfScheduleDays;
this.context = context;
dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
......
......@@ -4,13 +4,14 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;
import android.widget.Toast;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.EventDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.SchedulingDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.decorators.SchedulesDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.decorators.NotAvailableDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.ServiceLocation;
import br.ufpr.c3sl.agendador.agendador.presenters.SchedulingPresenter;
......@@ -27,9 +28,9 @@ public class LocationSpinnerListener implements AdapterView.OnItemSelectedListen
private List<ServiceLocation> serviceLocations;
private EventDecorator decorator;
private SchedulesDecorator schedulesDecorator;
private SchedulingDecorator schedulingDecorator;
private NotAvailableDecorator notAvailableDecorator;
private MaterialCalendarView mcv;
......@@ -58,8 +59,8 @@ public class LocationSpinnerListener implements AdapterView.OnItemSelectedListen
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
if (userSelect && serviceLocations != null && serviceLocations.size() > 0) {
mcv.setSelectionMode(MaterialCalendarView.SELECTION_MODE_SINGLE);
decorator.setScheduleType(pos);
schedulingDecorator.setScheduleType(pos);
schedulesDecorator.setScheduleType(pos);
notAvailableDecorator.setScheduleType(pos);
mcv.invalidateDecorators();
userSelect = false;
......@@ -81,12 +82,12 @@ public class LocationSpinnerListener implements AdapterView.OnItemSelectedListen
this.userSelect = userSelect;
}
public void setDecorator(EventDecorator decorator) {
this.decorator = decorator;
public void setSchedulesDecorator(SchedulesDecorator schedulesDecorator) {
this.schedulesDecorator = schedulesDecorator;
}
public void setSchedulingDecorator(SchedulingDecorator schedulingDecorator) {
this.schedulingDecorator = schedulingDecorator;
public void setNotAvailableDecorator(NotAvailableDecorator notAvailableDecorator) {
this.notAvailableDecorator = notAvailableDecorator;
}
......
......@@ -4,14 +4,13 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;
import android.widget.Toast;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.EventDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.SchedulingDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.decorators.SchedulesDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.decorators.NotAvailableDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.SectorInput;
import br.ufpr.c3sl.agendador.agendador.presenters.SchedulingPresenter;
......@@ -34,9 +33,9 @@ public class SectorSpinnerListener implements AdapterView.OnItemSelectedListener
private String[] days_short, months_short;
private EventDecorator decorator;
private SchedulesDecorator schedulesDecorator;
private SchedulingDecorator schedulingDecorator;
private NotAvailableDecorator notAvailableDecorator;
public SectorSpinnerListener(SchedulingPresenter presenter, List<SectorInput> sectorList, MaterialCalendarView mcv,
TextView calendarHeaderYear, TextView calendarHeaderDayHour, String[] days_short, String[] months_short){
......@@ -63,11 +62,11 @@ public class SectorSpinnerListener implements AdapterView.OnItemSelectedListener
userSelect = false;
Utils.updateCalendarHeaderDate(mcv, tv_calendarHeaderYear, tv_calendarHeaderDayHour, days_short, months_short, null);
if(decorator != null){
decorator.setScheduleType(EventDecorator.INVALID_STATE);
if(schedulesDecorator != null){
schedulesDecorator.setScheduleType(SchedulesDecorator.INVALID_STATE);
}
if(schedulingDecorator != null){
schedulingDecorator.setScheduleType(SchedulingDecorator.INVALID_STATE);
if(notAvailableDecorator != null){
notAvailableDecorator.setScheduleType(NotAvailableDecorator.INVALID_STATE);
}
mcv.invalidateDecorators();
......@@ -76,14 +75,13 @@ public class SectorSpinnerListener implements AdapterView.OnItemSelectedListener
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
public void setDecorator(EventDecorator decorator) {
this.decorator = decorator;
public void setSchedulesDecorator(SchedulesDecorator schedulesDecorator) {
this.schedulesDecorator = schedulesDecorator;
}
public void setSchedulingDecorator(SchedulingDecorator schedulingDecorator) {
this.schedulingDecorator = schedulingDecorator;
public void setNotAvailableDecorator(NotAvailableDecorator notAvailableDecorator) {
this.notAvailableDecorator = notAvailableDecorator;
}
}
......@@ -9,8 +9,8 @@ import com.prolificinteractive.materialcalendarview.MaterialCalendarView;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.EventDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.SchedulingDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.decorators.SchedulesDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.decorators.NotAvailableDecorator;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.models.ServiceType;
import br.ufpr.c3sl.agendador.agendador.presenters.SchedulingPresenter;
......@@ -33,9 +33,9 @@ public class ServiceTypeSpinnerListener implements AdapterView.OnItemSelectedLis
private String[] days_short, months_short;
private EventDecorator decorator;
private SchedulesDecorator schedulesDecorator;
private SchedulingDecorator schedulingDecorator;
private NotAvailableDecorator notAvailableDecorator;
public ServiceTypeSpinnerListener(SchedulingPresenter presenter, MaterialCalendarView mcv, TextView calendarHeaderYear,
......@@ -62,11 +62,11 @@ public class ServiceTypeSpinnerListener implements AdapterView.OnItemSelectedLis
Utils.updateCalendarHeaderDate(mcv, tv_calendarHeaderYear, tv_calendarHeaderDayHour, days_short, months_short, null);
if(decorator != null){
decorator.setScheduleType(EventDecorator.INVALID_STATE);
if(schedulesDecorator != null){
schedulesDecorator.setScheduleType(SchedulesDecorator.INVALID_STATE);
}
if(schedulingDecorator != null){
schedulingDecorator.setScheduleType(SchedulingDecorator.INVALID_STATE);
if(notAvailableDecorator != null){
notAvailableDecorator.setScheduleType(NotAvailableDecorator.INVALID_STATE);
}
mcv.invalidateDecorators();
......@@ -75,7 +75,6 @@ public class ServiceTypeSpinnerListener implements AdapterView.OnItemSelectedLis
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
public void setServiceTypes(List<ServiceType> serviceTypes) {
......@@ -86,12 +85,12 @@ public class ServiceTypeSpinnerListener implements AdapterView.OnItemSelectedLis
this.userSelect = userSelect;
}
public void setDecorator(EventDecorator decorator) {
this.decorator = decorator;
public void setSchedulesDecorator(SchedulesDecorator schedulesDecorator) {
this.schedulesDecorator = schedulesDecorator;
}
public void setSchedulingDecorator(SchedulingDecorator schedulingDecorator) {
this.schedulingDecorator = schedulingDecorator;
public void setNotAvailableDecorator(NotAvailableDecorator notAvailableDecorator) {
this.notAvailableDecorator = notAvailableDecorator;
}
}
......@@ -4,11 +4,8 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
import java.text.DateFormat;
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;
......@@ -126,8 +123,6 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
Headers headers = response.headers();
int status = response.code();
List<ServiceLocation> serviceLocations = response.body();
// TODO: 11/07/17 formatador de data.
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.getDefault());
switch (status) {
case 200:
Log.d("Server response", getClass().getName() + " SCHEDULES: 200 - Sucesso!");
......@@ -150,7 +145,4 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
}
// TODO: 07/07/17 apagar
//public Context getContext(){return context;}
}
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