esta guardar e nao esta a entar no perfil
This commit is contained in:
@@ -84,7 +84,7 @@ public class ScheduleAppointmentFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
// Put month on left, day on right
|
||||
// Put day on left, month on right
|
||||
int daySpinnerId = android.content.res.Resources.getSystem().getIdentifier("day", "id", "android");
|
||||
int monthSpinnerId = android.content.res.Resources.getSystem().getIdentifier("month", "id", "android");
|
||||
if (daySpinnerId != 0 && monthSpinnerId != 0) {
|
||||
@@ -95,9 +95,10 @@ public class ScheduleAppointmentFragment extends Fragment {
|
||||
if (parent != null && parent.equals(monthSpinner.getParent())) {
|
||||
int dIndex = parent.indexOfChild(daySpinner);
|
||||
int mIndex = parent.indexOfChild(monthSpinner);
|
||||
if (mIndex > dIndex) {
|
||||
parent.removeView(monthSpinner);
|
||||
parent.addView(monthSpinner, dIndex);
|
||||
// We want Day to be before Month (Day on Left, Month on Right)
|
||||
if (dIndex > mIndex) {
|
||||
parent.removeView(daySpinner);
|
||||
parent.addView(daySpinner, mIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ScheduleViewModel extends AndroidViewModel {
|
||||
private void loadTimeSlots(String date) {
|
||||
// Init slots immediately to prevent "disappearing" hours while waiting for
|
||||
// network.
|
||||
timeSlots.setValue(generateTimeSlots(new ArrayList<>()));
|
||||
timeSlots.setValue(generateTimeSlots(new ArrayList<>(), date));
|
||||
|
||||
if (auth.getCurrentUser() == null)
|
||||
return;
|
||||
@@ -88,7 +88,7 @@ public class ScheduleViewModel extends AndroidViewModel {
|
||||
bookedTimes.add(appt.time);
|
||||
}
|
||||
}
|
||||
List<TimeSlot> slots = generateTimeSlots(bookedTimes);
|
||||
List<TimeSlot> slots = generateTimeSlots(bookedTimes, date);
|
||||
timeSlots.setValue(slots);
|
||||
} else {
|
||||
Log.e("ScheduleViewModel", "Error getting booked slots", task.getException());
|
||||
@@ -96,14 +96,34 @@ public class ScheduleViewModel extends AndroidViewModel {
|
||||
});
|
||||
}
|
||||
|
||||
private List<TimeSlot> generateTimeSlots(List<String> bookedTimes) {
|
||||
private List<TimeSlot> generateTimeSlots(List<String> bookedTimes, String selectedDateStr) {
|
||||
List<TimeSlot> slots = new ArrayList<>();
|
||||
int startHour = 8;
|
||||
int endHour = 20;
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
boolean isToday = false;
|
||||
|
||||
if (selectedDateStr != null) {
|
||||
String todayStr = String.format("%02d/%02d/%04d",
|
||||
now.get(Calendar.DAY_OF_MONTH),
|
||||
now.get(Calendar.MONTH) + 1,
|
||||
now.get(Calendar.YEAR));
|
||||
if (todayStr.equals(selectedDateStr)) {
|
||||
isToday = true;
|
||||
}
|
||||
}
|
||||
|
||||
int currentHour = now.get(Calendar.HOUR_OF_DAY);
|
||||
int currentMinute = now.get(Calendar.MINUTE);
|
||||
|
||||
for (int hour = startHour; hour < endHour; hour++) {
|
||||
addSlot(slots, String.format("%02d:00", hour), bookedTimes);
|
||||
addSlot(slots, String.format("%02d:30", hour), bookedTimes);
|
||||
if (!isToday || hour > currentHour || (hour == currentHour && 0 > currentMinute)) {
|
||||
addSlot(slots, String.format("%02d:00", hour), bookedTimes);
|
||||
}
|
||||
if (!isToday || hour > currentHour || (hour == currentHour && 30 > currentMinute)) {
|
||||
addSlot(slots, String.format("%02d:30", hour), bookedTimes);
|
||||
}
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user