35 |
ProgressDialog pgDialog; |
ProgressDialog pgDialog; |
36 |
|
|
37 |
DepartureFetcher fetcher; |
DepartureFetcher fetcher; |
38 |
int stationId; |
|
39 |
|
StationBean station; |
|
double latitude,longitude; |
|
40 |
|
|
41 |
@SuppressWarnings("unchecked") |
@SuppressWarnings("unchecked") |
42 |
@Override |
@Override |
48 |
setListAdapter(adapter); |
setListAdapter(adapter); |
49 |
|
|
50 |
Intent launchedBy = getIntent(); |
Intent launchedBy = getIntent(); |
51 |
|
|
52 |
|
station = (StationBean) launchedBy.getSerializableExtra("stationbean"); |
53 |
|
|
54 |
latitude = launchedBy.getDoubleExtra("latitude", 0.0); |
((TextView) findViewById(R.id.stationName)).setText( station.getName() ); |
55 |
longitude = launchedBy.getDoubleExtra("longitude", 0.0); |
|
|
|
|
|
String name = launchedBy.getStringExtra("name"); |
|
|
((TextView) findViewById(R.id.stationName)).setText( name ); |
|
56 |
|
|
57 |
String address = launchedBy.getStringExtra("address"); |
((TextView) findViewById(R.id.stationAddr)).setText( station.getAddress() ); |
|
((TextView) findViewById(R.id.stationAddr)).setText( address ); |
|
58 |
|
|
|
stationId = launchedBy.getIntExtra("stationid", -1); |
|
59 |
|
|
60 |
findViewById(R.id.header).setOnClickListener( mapLauncher ); |
findViewById(R.id.header).setOnClickListener( mapLauncher ); |
61 |
|
|
62 |
NumberFormat format = NumberFormat.getNumberInstance(); |
NumberFormat format = NumberFormat.getNumberInstance(); |
63 |
format.setMaximumFractionDigits(1); |
format.setMaximumFractionDigits(1); |
64 |
format.setMinimumFractionDigits(1); |
format.setMinimumFractionDigits(1); |
|
int distance = launchedBy.getIntExtra("distance", 0); |
|
|
((TextView) findViewById(R.id.stationDistance)).setText( format.format((double)distance/1000.0) + " km." ); |
|
|
|
|
65 |
|
|
66 |
provider = ProviderFactory.getDepartureProvider(); |
|
67 |
|
int distance = station.getDistance(); |
68 |
|
((TextView) findViewById(R.id.stationDistance)).setText( format.format((double)distance/1000.0) + " km." ); |
69 |
|
|
70 |
if (savedInstanceState == null) { |
|
71 |
startDepartureFetcher(); |
if (station.isRegional() == false && station.isSTrain() == false) { |
72 |
|
getListView().setVisibility( View.GONE ); |
73 |
|
findViewById(R.id.metroonly).setVisibility( View.VISIBLE ); |
74 |
|
|
75 |
} else { |
} else { |
76 |
departures = (List<DepartureBean>) savedInstanceState.getSerializable("departures"); |
provider = ProviderFactory.getDepartureProvider(); |
77 |
adapter.setDepartures(departures); |
|
78 |
selectedItemId = savedInstanceState.getInt("selectedItemId"); |
if (savedInstanceState == null) { |
79 |
|
startDepartureFetcher(); |
80 |
|
} else { |
81 |
|
departures = (List<DepartureBean>) savedInstanceState.getSerializable("departures"); |
82 |
|
adapter.setDepartures(departures); |
83 |
|
selectedItemId = savedInstanceState.getInt("selectedItemId"); |
84 |
|
} |
85 |
} |
} |
86 |
} |
} |
87 |
|
|
139 |
void startDepartureFetcher() { |
void startDepartureFetcher() { |
140 |
showDialog(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
141 |
fetcher = new DepartureFetcher(); |
fetcher = new DepartureFetcher(); |
142 |
fetcher.execute(stationId); |
fetcher.execute(station.getId()); |
143 |
} |
} |
144 |
|
|
145 |
class DialogDismisser implements View.OnClickListener { |
class DialogDismisser implements View.OnClickListener { |
158 |
|
|
159 |
View.OnClickListener mapLauncher = new View.OnClickListener() { |
View.OnClickListener mapLauncher = new View.OnClickListener() { |
160 |
@Override |
@Override |
161 |
public void onClick(View v) { |
public void onClick(View v) { |
162 |
Uri uri = Uri.parse("geo:" + latitude + "," + longitude); |
Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude()); |
163 |
startActivity( new Intent(Intent.ACTION_VIEW, uri)); |
startActivity( new Intent(Intent.ACTION_VIEW, uri)); |
164 |
} |
} |
165 |
}; |
}; |