--- android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2011/04/05 05:31:32 1262 +++ android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2011/05/02 17:14:29 1423 @@ -31,7 +31,7 @@ import dk.thoerup.android.traininfo.common.DepartureEntry; import dk.thoerup.android.traininfo.common.MetroBean; import dk.thoerup.android.traininfo.common.MetroBean.MetroEntry; -import dk.thoerup.android.traininfo.common.StationBean.StationEntry; +import dk.thoerup.android.traininfo.common.StationEntry; import dk.thoerup.traininfo.provider.DepartureProvider; import dk.thoerup.traininfo.provider.MetroProvider; import dk.thoerup.traininfo.provider.ProviderFactory; @@ -429,8 +429,8 @@ pgDialog.dismiss(); - - if (departures != null) { + + if (departures != null && departures.errorCode == 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); @@ -452,15 +452,22 @@ }); } - if (departures.entries.size() != 0) { + if (departures.entries.size() == 0) { int msgId = (arrival==false) ? R.string.departurelist_nodepartures : R.string.departurelist_noarrivals; MessageBox.showMessage(DepartureList.this, getString(msgId), false); } } else { // communication or parse error commFailCounter++; - AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this); - builder.setMessage("Error finding departures"); + AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this); + + if (departures != null && departures.errorCode != null ) { //got an error xml back + commFailCounter = 10; + builder.setMessage( getString(R.string.no_backend) ); + } else { + builder.setMessage( getString(R.string.departurelist_fetcherror) ); + } builder.setCancelable(true); + if (commFailCounter < 3) { builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { @@ -477,7 +484,7 @@ } }); - try { + try { //TODO: is this still necessary after the 0.9.4.1 fix ? builder.show(); } catch (android.view.WindowManager.BadTokenException e) { Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running @@ -583,11 +590,11 @@ builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); - DepartureList.this.finish(); + DepartureList.this.finish(); //TODO: should we really close the activity ?? } }); - try { + try { //TODO: is this still necessary after the 0.9.4.1 fix ? builder.show(); } catch (android.view.WindowManager.BadTokenException e) { Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running