diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/services/updates/Updates.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/services/updates/Updates.java index 1137f78f1..4eca65071 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/services/updates/Updates.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/services/updates/Updates.java @@ -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; } }); }