/[projects]/android/CheckUpdates/src/dk/thoerup/checkupdates/CheckUpdates.java
ViewVC logotype

Diff of /android/CheckUpdates/src/dk/thoerup/checkupdates/CheckUpdates.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 723 by torben, Mon May 10 22:10:10 2010 UTC revision 724 by torben, Mon May 10 22:22:09 2010 UTC
# Line 23  import android.util.Log; Line 23  import android.util.Log;
23  public class CheckUpdates {  public class CheckUpdates {
24          public static long TIMESPAN_DAY = 24*60*60*1000; // one day          public static long TIMESPAN_DAY = 24*60*60*1000; // one day
25          final static String CHECKUPDATES = "CheckUpdates";          final static String CHECKUPDATES = "CheckUpdates";
26            final static String LASTCHECK = "lastcheck";
27                    
28          int versionCode;          int versionCode;
29          String versionName;          String versionName;
# Line 40  public class CheckUpdates { Line 41  public class CheckUpdates {
41                  this.title = title;                  this.title = title;
42                                    
43                  SharedPreferences prefs = context.getSharedPreferences(CHECKUPDATES, Context.MODE_PRIVATE);                  SharedPreferences prefs = context.getSharedPreferences(CHECKUPDATES, Context.MODE_PRIVATE);
44                  long lastCheck = prefs.getLong("lastcheck", 0);                  long lastCheck = prefs.getLong(LASTCHECK, 0);
45    
46                  long now = System.currentTimeMillis(); //should i use  android.os.SystemClock.elapsedRealtime() instead ?                  long now = System.currentTimeMillis(); //should i use  android.os.SystemClock.elapsedRealtime() instead ?
47                    Log.i(CHECKUPDATES, "Now=" + now + ",  lastCheck=" + lastCheck + ", lastCheck+timespan=" + (lastCheck + TIMESPAN_DAY) );
48                                    
49                  if ( now > (lastCheck+TIMESPAN_DAY) ){                  if ( now > (lastCheck+TIMESPAN_DAY) ){
50    
# Line 123  public class CheckUpdates { Line 125  public class CheckUpdates {
125                          Log.i(CHECKUPDATES, "result=" + result + ", newestVersion" + newestVersion + ", versionCode=" + versionCode);                          Log.i(CHECKUPDATES, "result=" + result + ", newestVersion" + newestVersion + ", versionCode=" + versionCode);
126                                                    
127                          if (result == true) {                          if (result == true) {
128                                    
129                                    long now = System.currentTimeMillis();
130                                    SharedPreferences prefs = context.getSharedPreferences(CHECKUPDATES, Context.MODE_PRIVATE);
131                                    //when done write
132                                    Editor edit = prefs.edit();
133                                    edit.putLong(LASTCHECK, now);
134                                    edit.commit();
135                                    
136                                  if (newestVersion > versionCode) {                                  if (newestVersion > versionCode) {
137                                          AlertDialog.Builder builder = new AlertDialog.Builder(context);                                          AlertDialog.Builder builder = new AlertDialog.Builder(context);
138                                          builder.setTitle(title);                                          builder.setTitle(title);
# Line 155  public class CheckUpdates { Line 165  public class CheckUpdates {
165                                                                                    
166                                  }                                  }
167                                                                    
                                 long now = System.currentTimeMillis();  
                                 SharedPreferences prefs = context.getSharedPreferences(CHECKUPDATES, Context.MODE_PRIVATE);  
                                 //when done write  
                                 Editor edit = prefs.edit();  
                                 edit.putLong("lastCheck", now);  
                                 edit.commit();  
168                          }                          }
169                                                    
170                  }                  }

Legend:
Removed from v.723  
changed lines
  Added in v.724

  ViewVC Help
Powered by ViewVC 1.1.20