EtdService no longer overlaps scheduled etd requests
This commit is contained in:
parent
0ec87c77e3
commit
3a2623ab96
@ -555,16 +555,27 @@ public class EtdService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private long mNextFetchClockTime = 0;
|
||||
|
||||
private void scheduleDepartureFetch(int millisUntilExecute) {
|
||||
mPendingEtdRequest = true;
|
||||
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) {
|
||||
mRunnableQueue.postDelayed(new Runnable() {
|
||||
|
Loading…
Reference in New Issue
Block a user