v0.8.2: added a 1 hour delay to the update checker
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.services.updates;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class Updates {
|
||||
|
||||
public static UpdateService service;
|
||||
@@ -29,25 +31,28 @@ public class Updates {
|
||||
return service != null;
|
||||
}
|
||||
|
||||
private static boolean updateChecked = false;
|
||||
private static Date lastCheck = null;
|
||||
private static final long CHECK_DELAY = 1000*60*60; //1 hour
|
||||
|
||||
public static void checkForUpdate(){
|
||||
if (!supportsUpdates() || updateChecked) return;
|
||||
if (!supportsUpdates()) return;
|
||||
if (lastCheck != null && (new Date().getTime() - lastCheck.getTime()) < CHECK_DELAY) return;
|
||||
|
||||
service.checkForUpdate(new UpdateService.UpdateResultCallback() {
|
||||
@Override
|
||||
public void onUpdateAvailable(AvailableUpdateData update) {
|
||||
updateChecked = true;
|
||||
lastCheck = new Date();
|
||||
updateData = update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNoUpdateFound() {
|
||||
updateChecked = true;
|
||||
lastCheck = new Date();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed() {
|
||||
updateChecked = false;
|
||||
lastCheck = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user