52
52
public class UpdateCheck implements Runnable {
53
53
Base base ;
54
54
55
- static final long ONE_DAY = 24 * 60 * 60 * 1000 ;
56
-
57
-
58
55
public UpdateCheck (Base base ) {
59
56
Thread thread = new Thread (this );
60
57
this .base = base ;
61
58
thread .start ();
62
59
}
63
60
64
-
65
61
public void run () {
66
- //System.out.println("checking for updates...");
62
+ // Ensure updates-check are made only once per day
63
+ String lastString = PreferencesData .get ("update.last" );
64
+ long now = System .currentTimeMillis ();
65
+ if (lastString != null ) {
66
+ final long ONE_DAY = 24 * 60 * 60 * 1000 ;
67
+ long when = Long .parseLong (lastString );
68
+ if ((now - when ) < ONE_DAY ) {
69
+ // don't annoy the shit outta people
70
+ return ;
71
+ }
72
+ }
73
+ PreferencesData .set ("update.last" , String .valueOf (now ));
67
74
75
+ // Set update id
68
76
long id ;
69
77
String idString = PreferencesData .get ("update.id" );
70
78
if (idString != null ) {
@@ -76,6 +84,7 @@ public void run() {
76
84
PreferencesData .set ("update.id" , String .valueOf (id ));
77
85
}
78
86
87
+ // Check for updates of the IDE
79
88
try {
80
89
String info ;
81
90
info = URLEncoder .encode (id + "\t " +
@@ -88,17 +97,6 @@ public void run() {
88
97
89
98
int latest = readInt ("https://www.arduino.cc/latest.txt?" + info );
90
99
91
- String lastString = PreferencesData .get ("update.last" );
92
- long now = System .currentTimeMillis ();
93
- if (lastString != null ) {
94
- long when = Long .parseLong (lastString );
95
- if (now - when < ONE_DAY ) {
96
- // don't annoy the shit outta people
97
- return ;
98
- }
99
- }
100
- PreferencesData .set ("update.last" , String .valueOf (now ));
101
-
102
100
String prompt =
103
101
tr ("A new version of Arduino is available,\n " +
104
102
"would you like to visit the Arduino download page?" );
0 commit comments