48 |
LocationLookup locator = null; |
LocationLookup locator = null; |
49 |
LocatorTask locatorTask; |
LocatorTask locatorTask; |
50 |
|
|
51 |
|
GeoPair location = new GeoPair(); |
52 |
|
|
53 |
boolean isRunning = false; |
boolean isRunning = false; |
54 |
List<StationBean> stations = new ArrayList<StationBean>(); |
List<StationBean> stations = new ArrayList<StationBean>(); |
55 |
|
|
73 |
} else { |
} else { |
74 |
stations = (ArrayList<StationBean>) savedInstanceState.getSerializable("stations"); |
stations = (ArrayList<StationBean>) savedInstanceState.getSerializable("stations"); |
75 |
adapter.setStations(stations); |
adapter.setStations(stations); |
76 |
|
location = (GeoPair) savedInstanceState.getSerializable("location"); |
77 |
} |
} |
78 |
} |
} |
79 |
|
|
80 |
|
|
81 |
@Override |
@Override |
82 |
public void onSaveInstanceState(Bundle outState) |
public void onSaveInstanceState(Bundle outState) |
83 |
{ |
{ |
84 |
if (dialog != null && dialog.isShowing()) |
if (dialog != null && dialog.isShowing()) |
85 |
dialog.dismiss(); |
dialog.dismiss(); |
86 |
outState.putSerializable("stations", (ArrayList<StationBean>) stations); |
outState.putSerializable("stations", (ArrayList<StationBean>) stations); |
87 |
|
outState.putSerializable("location", location); |
88 |
} |
} |
89 |
|
|
90 |
|
|
105 |
case OPTIONS_MAP: |
case OPTIONS_MAP: |
106 |
|
|
107 |
Intent intent = new Intent(this,StationMapView.class); |
Intent intent = new Intent(this,StationMapView.class); |
108 |
intent.putExtra("userlocation", GeoPair.fromLocation(locator.getLocation()) ); |
intent.putExtra("userlocation", location ); |
109 |
|
|
110 |
ArrayList<GeoPair> stationPoints = new ArrayList<GeoPair>(); |
ArrayList<GeoPair> stationPoints = new ArrayList<GeoPair>(); |
111 |
for (StationBean st : stations ) { |
for (StationBean st : stations ) { |
112 |
stationPoints.add( new GeoPair(st.getLatitude(), st.getLongitude()) ); |
stationPoints.add( new GeoPair(st.getLatitude(), st.getLongitude(), st.getName()) ); |
113 |
} |
} |
114 |
|
|
115 |
intent.putExtra("stations", stationPoints); |
intent.putExtra("stations", stationPoints); |
117 |
startActivity(intent); |
startActivity(intent); |
118 |
retval = true; |
retval = true; |
119 |
break; |
break; |
120 |
|
case OPTIONS_ABOUT: |
121 |
|
String ver = this.getResources().getString(R.string.app_version); |
122 |
|
|
123 |
|
StringBuffer message = new StringBuffer(); |
124 |
|
message.append("TrainInfo DK v").append(ver).append("\n"); |
125 |
|
message.append("By Torben Nielsen\n"); |
126 |
|
|
127 |
|
MessageBox.showMessage(this, message.toString()); |
128 |
|
retval = true; |
129 |
|
break; |
130 |
default: |
default: |
131 |
retval = super.onOptionsItemSelected(item); |
retval = super.onOptionsItemSelected(item); |
132 |
} |
} |
182 |
dismissDialog(DLG_PROGRESS); |
dismissDialog(DLG_PROGRESS); |
183 |
|
|
184 |
startLocatorTask(); |
startLocatorTask(); |
185 |
|
location = GeoPair.fromLocation( locator.getLocation() ); |
186 |
|
|
187 |
break; |
break; |
188 |
|
|