File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed
arduino-core/src/processing/app Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -60,28 +60,24 @@ public UpdateCheck(Base base) {
60
60
61
61
public void run () {
62
62
// Ensure updates-check are made only once per day
63
- String lastString = PreferencesData .get ("update.last" );
63
+ Long when = PreferencesData .getLong ("update.last" );
64
64
long now = System .currentTimeMillis ();
65
- if (lastString != null ) {
66
- final long ONE_DAY = 24 * 60 * 60 * 1000 ;
67
- long when = Long .parseLong (lastString );
65
+ final long ONE_DAY = 24 * 60 * 60 * 1000 ;
66
+ if (when != null ) {
68
67
if ((now - when ) < ONE_DAY ) {
69
68
// don't annoy the shit outta people
70
69
return ;
71
70
}
72
71
}
73
- PreferencesData .set ("update.last" , String . valueOf ( now ) );
72
+ PreferencesData .setLong ("update.last" , now );
74
73
75
74
// Set update id
76
- long id ;
77
- String idString = PreferencesData .get ("update.id" );
78
- if (idString != null ) {
79
- id = Long .parseLong (idString );
80
- } else {
75
+ Long id = PreferencesData .getLong ("update.id" );
76
+ if (id == null ) {
81
77
// generate a random id in case none exists yet
82
78
Random r = new Random ();
83
79
id = r .nextLong ();
84
- PreferencesData .set ("update.id" , String . valueOf ( id ) );
80
+ PreferencesData .setLong ("update.id" , id );
85
81
}
86
82
87
83
// Check for updates of the IDE
Original file line number Diff line number Diff line change @@ -282,4 +282,16 @@ public static boolean areInsecurePackagesAllowed() {
282
282
}
283
283
return getBoolean (Constants .PREF_CONTRIBUTIONS_TRUST_ALL , false );
284
284
}
285
+
286
+ public static void setLong (String k , long v ) {
287
+ set (k , String .valueOf (v ));
288
+ }
289
+
290
+ public static Long getLong (String k ) {
291
+ try {
292
+ return Long .parseLong (get (k ));
293
+ } catch (NumberFormatException e ) {
294
+ return null ;
295
+ }
296
+ }
285
297
}
You can’t perform that action at this time.
0 commit comments