private boolean isArrivalAndDeparturePairInRange(
ArrivalAndDepartureInstance instanceFrom,
ArrivalAndDepartureInstance instanceTo, Date timeFrom, Date timeTo,
boolean findDepartures) {
ArrivalAndDepartureInstance instance = findDepartures ? instanceFrom
: instanceTo;
if (timeFrom != null) {
boolean schedInRange = instance.getScheduledDepartureTime() >= timeFrom.getTime();
boolean realTimeInRange = true;
if (instance.isPredictedDepartureTimeSet())
realTimeInRange = instance.getPredictedDepartureTime() >= timeFrom.getTime();
if (!(schedInRange || realTimeInRange))
return false;
}
if (timeTo != null) {
boolean schedInRange = instance.getScheduledArrivalTime() <= timeTo.getTime();
boolean realTimeInRange = true;
if (instance.isPredictedArrivalTimeSet())
realTimeInRange = instance.getPredictedArrivalTime() <= timeTo.getTime();
if (!(schedInRange || realTimeInRange))
return false;
}
return true;