// start a few days early so that we can get ones that start before but extend into this range
for (Date current = getAdjustedDate(start, -3); current.before(end); current = getAdjustedDate(current, +1)) {
int events = mRandom.nextInt(4);
for (int i = 1; i <= events; i++) {
IEvent evt = createRandomEvent(current, counter++);
if (evt.getStartTime().before(start)) {
// this is one that starts out of range, so let's only add it if it extends into range
// this mimics what a well-behaved provider should do according to contract
if (evt.getEndTime() == null || evt.getEndTime().before(start)) {
counter--;
continue;
}
}
mEvents.add(evt);