4 |
import java.util.List; |
import java.util.List; |
5 |
|
|
6 |
|
|
7 |
|
import android.app.Activity; |
8 |
import android.app.AlertDialog; |
import android.app.AlertDialog; |
9 |
import android.app.Dialog; |
import android.app.Dialog; |
10 |
import android.app.ListActivity; |
import android.app.ListActivity; |
70 |
StationsFetchedHandler stationsFetched = new StationsFetchedHandler(); |
StationsFetchedHandler stationsFetched = new StationsFetchedHandler(); |
71 |
|
|
72 |
GeoPair location = new GeoPair(); |
GeoPair location = new GeoPair(); |
73 |
|
|
74 |
|
boolean isLaunchedforShortcut; |
75 |
boolean isRunning = false; |
boolean isRunning = false; |
76 |
List<StationBean> stations = new ArrayList<StationBean>(); |
List<StationBean> stations = new ArrayList<StationBean>(); |
77 |
|
|
113 |
listType = (WelcomeScreen.ListType) getIntent().getSerializableExtra("type"); |
listType = (WelcomeScreen.ListType) getIntent().getSerializableExtra("type"); |
114 |
setTitle(); |
setTitle(); |
115 |
|
|
116 |
|
isLaunchedforShortcut = getIntent().getBooleanExtra("shortcut", false); |
117 |
|
|
118 |
if (savedInstanceState == null) { |
if (savedInstanceState == null) { |
119 |
|
|
120 |
|
|
139 |
} |
} |
140 |
|
|
141 |
} |
} |
142 |
|
|
143 |
|
|
144 |
|
@Override |
145 |
|
protected void onDestroy() { |
146 |
|
super.onDestroy(); |
147 |
|
|
148 |
|
if (findStationsTask != null) { |
149 |
|
findStationsTask.cancel(true); |
150 |
|
} |
151 |
|
} |
152 |
|
|
153 |
|
|
154 |
protected void setTitle() { |
protected void setTitle() { |
155 |
String dialogTitle = getResources().getString(app_name); |
String dialogTitle = getResources().getString(app_name); |
156 |
switch (listType) { |
switch (listType) { |
270 |
message.append( getString(stationlist_nolocation) ); |
message.append( getString(stationlist_nolocation) ); |
271 |
} |
} |
272 |
|
|
273 |
MessageBox.showMessage(this, message.toString()); |
MessageBox.showMessage(this, message.toString(), false); |
274 |
break; |
break; |
275 |
default: |
default: |
276 |
retval = super.onOptionsItemSelected(item); |
retval = super.onOptionsItemSelected(item); |
370 |
|
|
371 |
StationBean station = stations.get(position); |
StationBean station = stations.get(position); |
372 |
|
|
373 |
Intent intent = new Intent(this, DepartureList.class); |
if (isLaunchedforShortcut == true) { |
374 |
intent.putExtra("stationbean", station); |
Intent i = new Intent(); |
375 |
startActivity(intent); |
i.putExtra("station", station); |
376 |
|
setResult(Activity.RESULT_OK, i); |
377 |
|
finish(); |
378 |
|
} else { |
379 |
|
Intent intent = new Intent(this, DepartureList.class); |
380 |
|
intent.putExtra("stationbean", station); |
381 |
|
startActivity(intent); |
382 |
|
} |
383 |
} |
} |
384 |
|
|
385 |
///////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////// |
449 |
|
|
450 |
case NOPROVIDER: |
case NOPROVIDER: |
451 |
dismissDialogSafe(DLG_PROGRESS); |
dismissDialogSafe(DLG_PROGRESS); |
452 |
MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider) ); |
MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); |
453 |
|
//StationList.this.finish(); |
454 |
break; |
break; |
455 |
case LOCATIONFIXTIMEOUT: |
case LOCATIONFIXTIMEOUT: |
456 |
if (isRunning) { |
if (isRunning) { |
551 |
showMessageAndClose(getString(stationlist_nostations)); |
showMessageAndClose(getString(stationlist_nostations)); |
552 |
} |
} |
553 |
stations = stationProvider.getStations(); |
stations = stationProvider.getStations(); |
554 |
|
|
555 |
|
StationList.this.getListView().invalidateViews(); |
556 |
adapter.setStations( stations ); |
adapter.setStations( stations ); |
557 |
|
|
558 |
|
|
559 |
} else { //communication or parse errors |
} else { //communication or parse errors |
560 |
AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this); |
AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this); |
561 |
builder.setMessage(getString(stationlist_nearbyerror)); |
builder.setMessage(getString(stationlist_fetcherror)); |
562 |
builder.setCancelable(true); |
builder.setCancelable(true); |
563 |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
564 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
598 |
builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { |
builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { |
599 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
600 |
dialog.dismiss(); |
dialog.dismiss(); |
601 |
|
StationList.this.finish(); |
602 |
} |
} |
603 |
}); |
}); |
604 |
|
|