--- android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2011/04/05 05:46:55 1263 +++ android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2011/05/03 12:35:34 1432 @@ -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; @@ -364,8 +364,12 @@ boolean res; switch(item.getItemId()) { case MENU_MAP: - Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude() + "?z=16"); - startActivity( new Intent(Intent.ACTION_VIEW, uri)); + try { + Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude() + "?z=16"); + startActivity( new Intent(Intent.ACTION_VIEW, uri)); + } catch (ActivityNotFoundException anfe) { + Toast.makeText(this, "Could not launch google maps", Toast.LENGTH_LONG).show(); + } res = true; break; case MENU_NOTIFICATIONS: @@ -429,9 +433,8 @@ pgDialog.dismiss(); - //TODO: differentiate whether it was a communication error with my backend - //or that the backend failed because bane.dk was unavailable - 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); @@ -453,15 +456,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) {