--- android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2011/04/05 07:54:45 1264 +++ android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java 2011/05/03 12:38:04 1433 @@ -11,6 +11,7 @@ import android.app.Dialog; import android.app.ListActivity; import android.app.ProgressDialog; +import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Typeface; @@ -27,11 +28,12 @@ import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; +import android.widget.Toast; import dk.thoerup.android.traininfo.common.DepartureBean; 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 +366,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 +435,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); @@ -459,9 +464,16 @@ } } 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) {