51 |
StationBean station; |
StationBean station; |
52 |
|
|
53 |
boolean arrival = false; |
boolean arrival = false; |
54 |
|
|
55 |
|
int commFailCounter = 0; |
56 |
|
|
57 |
@Override |
@Override |
58 |
protected void onCreate(Bundle savedInstanceState) { |
protected void onCreate(Bundle savedInstanceState) { |
289 |
pgDialog.dismiss(); |
pgDialog.dismiss(); |
290 |
|
|
291 |
if (departures != null) { |
if (departures != null) { |
292 |
|
commFailCounter = 0; |
293 |
DepartureList.this.getListView().setVisibility(View.GONE); //Experimental, inspired by http://osdir.com/ml/Android-Developers/2010-04/msg01198.html |
DepartureList.this.getListView().setVisibility(View.GONE); //Experimental, inspired by http://osdir.com/ml/Android-Developers/2010-04/msg01198.html |
294 |
adapter.setDepartures(departures.entries); |
adapter.setDepartures(departures.entries); |
295 |
DepartureList.this.getListView().setVisibility(View.VISIBLE); |
DepartureList.this.getListView().setVisibility(View.VISIBLE); |
303 |
MessageBox.showMessage(DepartureList.this, "No departures found", true); |
MessageBox.showMessage(DepartureList.this, "No departures found", true); |
304 |
} |
} |
305 |
} else { // communication or parse error |
} else { // communication or parse error |
306 |
|
commFailCounter++; |
307 |
AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this); |
AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this); |
308 |
builder.setMessage("Error finding departures"); |
builder.setMessage("Error finding departures"); |
309 |
builder.setCancelable(true); |
builder.setCancelable(true); |
310 |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
if (commFailCounter < 3) { |
311 |
public void onClick(DialogInterface dialog, int id) { |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
312 |
dialog.dismiss(); |
public void onClick(DialogInterface dialog, int id) { |
313 |
startDepartureFetcher(); |
dialog.dismiss(); |
314 |
|
startDepartureFetcher(); |
315 |
} |
|
316 |
}); |
} |
317 |
|
}); |
318 |
|
} |
319 |
builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { |
builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { |
320 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
321 |
dialog.dismiss(); |
dialog.dismiss(); |