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
1 changed files with 18 additions and 7 deletions

View File

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