--- android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2010/08/12 10:01:24 1016 +++ android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2010/08/24 19:36:27 1017 @@ -51,7 +51,8 @@ StationBean station; boolean arrival = false; - + + int commFailCounter = 0; @Override protected void onCreate(Bundle savedInstanceState) { @@ -288,6 +289,7 @@ pgDialog.dismiss(); if (departures != null) { + commFailCounter = 0; DepartureList.this.getListView().setVisibility(View.GONE); //Experimental, inspired by http://osdir.com/ml/Android-Developers/2010-04/msg01198.html adapter.setDepartures(departures.entries); DepartureList.this.getListView().setVisibility(View.VISIBLE); @@ -301,16 +303,19 @@ MessageBox.showMessage(DepartureList.this, "No departures found", true); } } else { // communication or parse error + commFailCounter++; AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this); builder.setMessage("Error finding departures"); builder.setCancelable(true); - builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); - startDepartureFetcher(); - - } - }); + if (commFailCounter < 3) { + builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + startDepartureFetcher(); + + } + }); + } builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss();