--- android/TrainInfo/src/dk/thoerup/traininfo/ShortcutActivity.java 2010/05/18 14:02:13 731 +++ android/TrainInfo/src/dk/thoerup/traininfo/ShortcutActivity.java 2010/10/01 17:47:49 1151 @@ -8,6 +8,8 @@ import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; +import android.widget.Toast; +import dk.thoerup.android.traininfo.common.StationBean.StationEntry; import dk.thoerup.traininfo.WelcomeScreen.ListType; public class ShortcutActivity extends Activity { @@ -16,7 +18,7 @@ final static int SHOW_STATIONS = 2000; - StationBean station; + StationEntry station; Button okBtn; @Override @@ -63,11 +65,16 @@ } else { //launched by the user clicking on the shortcut String stationStr = intent.getStringExtra("station"); - StationBean station = StationBean.fromCSV(stationStr); + + if (stationStr != null) { //haven't reproduced it, but got a stacktrace where stationStr apparently was null + StationEntry station = StationEntry.fromCSV(stationStr); - Intent launcher = new Intent( this, DepartureList.class ); - launcher.putExtra("stationbean", station); - startActivityForResult(launcher, SHOW_DEPARTURES); + Intent launcher = new Intent( this, DepartureList.class ); + launcher.putExtra("stationbean", station); + startActivityForResult(launcher, SHOW_DEPARTURES); + } else { + Toast.makeText(this, "Invalid TrainInfo shortcut - please delete and re-create", Toast.LENGTH_LONG).show(); + } } } @@ -98,7 +105,7 @@ * with an appropriate Uri for your content, but any Intent will work here as long as it * triggers the desired action within your Activity. */ - private void setupShortcut(StationBean station) { + private void setupShortcut(StationEntry station) { // First, set up the shortcut intent. Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName(this, this.getClass().getName()); @@ -128,7 +135,7 @@ case SHOW_STATIONS: if (data != null) { - station = (StationBean) data.getSerializableExtra("station"); + station = (StationEntry) data.getSerializableExtra("station"); if (station != null) { okBtn.setEnabled(true);