2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
import java.io.InvalidClassException; |
6 |
|
|
7 |
import android.app.Activity; |
import android.app.Activity; |
8 |
import android.app.ProgressDialog; |
import android.app.ProgressDialog; |
9 |
import android.content.Intent; |
import android.content.Intent; |
88 |
|
|
89 |
if (sp instanceof OfflineStationProvider ) { |
if (sp instanceof OfflineStationProvider ) { |
90 |
OfflineStationProvider osp = (OfflineStationProvider) sp; |
OfflineStationProvider osp = (OfflineStationProvider) sp; |
91 |
try { |
long last = prefs.getLong(stationsreload, 0); |
92 |
|
long now = System.currentTimeMillis(); |
93 |
long last = prefs.getLong(stationsreload, 0); |
Log.i("TrainInfo", "Last Load: " + last); |
94 |
long now = System.currentTimeMillis(); |
|
95 |
|
if ( (now-last) > (14*24*60*60*1000) ) { |
96 |
|
new StationLoader(osp).execute( (Void)null); |
97 |
|
} else { |
98 |
|
|
99 |
|
boolean didLoad = false; |
100 |
|
|
101 |
Log.i("TrainInfo", "Last Load: " + last); |
try { |
102 |
|
didLoad = osp.loadStations(this); |
103 |
|
} |
104 |
|
catch (InvalidClassException e) { |
105 |
|
Log.i("TrainInfo", "invalid class - do a new download of stationlist"); |
106 |
|
} |
107 |
|
catch (Exception e) { |
108 |
|
Toast.makeText(this, "" + e.getMessage(), Toast.LENGTH_SHORT).show(); |
109 |
|
Log.e("TrainInfo", "load error", e); |
110 |
|
} |
111 |
|
|
112 |
if ( (now-last) > (14*24*60*60*1000) ) { |
if (didLoad == false) { |
113 |
new StationLoader(osp).execute( (Void)null); |
new StationLoader(osp).execute( (Void)null); |
|
} else { |
|
|
|
|
|
boolean didLoad = osp.loadStations(this); |
|
|
|
|
|
if (didLoad == false) { |
|
|
new StationLoader(osp).execute( (Void)null); |
|
|
} |
|
114 |
} |
} |
|
|
|
|
} catch (Exception e) { |
|
|
Toast.makeText(this, "" + e.getMessage(), Toast.LENGTH_SHORT).show(); |
|
115 |
} |
} |
116 |
|
|
117 |
} |
} |
118 |
} |
} |
119 |
|
|