EtdService no longer overlaps scheduled etd requests

This commit is contained in:
Doug Keen 2012-09-17 08:52:05 -07:00
parent 0ec87c77e3
commit 3a2623ab96

View File

@ -555,15 +555,26 @@ public class EtdService extends Service {
} }
} }
private long mNextFetchClockTime = 0;
private void scheduleDepartureFetch(int millisUntilExecute) { private void scheduleDepartureFetch(int millisUntilExecute) {
mPendingEtdRequest = true; mPendingEtdRequest = true;
mRunnableQueue.postDelayed(new Runnable() { long now = System.currentTimeMillis();
public void run() { long requestedFetchTime = now + millisUntilExecute;
fetchLatestDepartures(); if (mNextFetchClockTime > now
} && mNextFetchClockTime < requestedFetchTime) {
}, millisUntilExecute); Log.d(Constants.TAG,
Log.d(Constants.TAG, "Scheduled another departure fetch in " "Did not schedule departure fetch, since one is already scheduled");
+ millisUntilExecute / 1000 + "s"); } else {
mRunnableQueue.postDelayed(new Runnable() {
public void run() {
fetchLatestDepartures();
}
}, millisUntilExecute);
mNextFetchClockTime = requestedFetchTime;
Log.d(Constants.TAG, "Scheduled another departure fetch in "
+ millisUntilExecute / 1000 + "s");
}
} }
private void scheduleScheduleInfoFetch(int millisUntilExecute) { private void scheduleScheduleInfoFetch(int millisUntilExecute) {