From d406230821296d29d5d630134ad62dfbc4eabcc5 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 3 Jul 2020 18:22:54 -0400 Subject: [PATCH] v0.8.2: added a 1 hour delay to the update checker --- .../services/updates/Updates.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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; } }); }