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;
|
package com.shatteredpixel.shatteredpixeldungeon.services.updates;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class Updates {
|
public class Updates {
|
||||||
|
|
||||||
public static UpdateService service;
|
public static UpdateService service;
|
||||||
@@ -29,25 +31,28 @@ public class Updates {
|
|||||||
return service != null;
|
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(){
|
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() {
|
service.checkForUpdate(new UpdateService.UpdateResultCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateAvailable(AvailableUpdateData update) {
|
public void onUpdateAvailable(AvailableUpdateData update) {
|
||||||
updateChecked = true;
|
lastCheck = new Date();
|
||||||
updateData = update;
|
updateData = update;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNoUpdateFound() {
|
public void onNoUpdateFound() {
|
||||||
updateChecked = true;
|
lastCheck = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionFailed() {
|
public void onConnectionFailed() {
|
||||||
updateChecked = false;
|
lastCheck = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user