23 |
import static dk.thoerup.traininfo.R.string.stationlist_nostations; |
import static dk.thoerup.traininfo.R.string.stationlist_nostations; |
24 |
import static dk.thoerup.traininfo.R.string.stationlist_obtainedby; |
import static dk.thoerup.traininfo.R.string.stationlist_obtainedby; |
25 |
import static dk.thoerup.traininfo.R.string.stationlist_removefavorite; |
import static dk.thoerup.traininfo.R.string.stationlist_removefavorite; |
26 |
|
import static dk.thoerup.traininfo.R.string.stationlist_satellitecount; |
27 |
import static dk.thoerup.traininfo.R.string.stationlist_search; |
import static dk.thoerup.traininfo.R.string.stationlist_search; |
28 |
import static dk.thoerup.traininfo.R.string.stationlist_stationadded; |
import static dk.thoerup.traininfo.R.string.stationlist_stationadded; |
29 |
import static dk.thoerup.traininfo.R.string.stationlist_stationmap; |
import static dk.thoerup.traininfo.R.string.stationlist_stationmap; |
31 |
import static dk.thoerup.traininfo.R.string.stationlist_stationsearch; |
import static dk.thoerup.traininfo.R.string.stationlist_stationsearch; |
32 |
import static dk.thoerup.traininfo.R.string.stationlist_twocharmin; |
import static dk.thoerup.traininfo.R.string.stationlist_twocharmin; |
33 |
import static dk.thoerup.traininfo.R.string.stationlist_waitforlocation; |
import static dk.thoerup.traininfo.R.string.stationlist_waitforlocation; |
|
import static dk.thoerup.traininfo.R.string.stationlist_satellitecount; |
|
34 |
|
|
35 |
import java.util.ArrayList; |
import java.util.ArrayList; |
36 |
|
|
48 |
import android.os.Bundle; |
import android.os.Bundle; |
49 |
import android.os.Handler; |
import android.os.Handler; |
50 |
import android.os.Message; |
import android.os.Message; |
51 |
|
import android.util.Log; |
52 |
import android.view.ContextMenu; |
import android.view.ContextMenu; |
53 |
import android.view.LayoutInflater; |
import android.view.LayoutInflater; |
54 |
import android.view.Menu; |
import android.view.Menu; |
150 |
|
|
151 |
switch (listType) { |
switch (listType) { |
152 |
case ListNearest: |
case ListNearest: |
153 |
startLookup(); |
startNearestLookup(); |
154 |
break; |
break; |
155 |
case ListSearch: |
case ListSearch: |
156 |
showDialog(DLG_STATIONNAME); |
showDialog(DLG_STATIONNAME); |
178 |
protected void onDestroy() { |
protected void onDestroy() { |
179 |
super.onDestroy(); |
super.onDestroy(); |
180 |
|
|
181 |
|
stationsFetched.removeMessages(0); |
182 |
|
|
183 |
|
|
184 |
if (locationLookup != null) { |
if (locationLookup != null) { |
185 |
locationLookup.stopSearch(); |
locationLookup.stopSearch(); |
327 |
dialog.dismiss(); |
dialog.dismiss(); |
328 |
String search = et.getText().toString().trim(); |
String search = et.getText().toString().trim(); |
329 |
if (search.length() >= 2) { |
if (search.length() >= 2) { |
330 |
startNameSearch(search); |
startNameLookup(search); |
331 |
} else { |
} else { |
332 |
showMessageAndClose( getString(stationlist_twocharmin) ); |
showMessageAndClose( getString(stationlist_twocharmin) ); |
333 |
} |
} |
383 |
///////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////// |
384 |
// |
// |
385 |
|
|
386 |
public void startLookup() { |
public void startNearestLookup() { |
387 |
dialogMessage = getString( stationlist_waitforlocation ); |
dialogMessage = getString( stationlist_waitforlocation ); |
388 |
showDialog(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
389 |
|
|
391 |
stationsFetched.sendEmptyMessageDelayed(0, 500); |
stationsFetched.sendEmptyMessageDelayed(0, 500); |
392 |
} |
} |
393 |
|
|
394 |
void startNameSearch(String name) { |
void startNameLookup(String name) { |
395 |
dialogMessage = getString( stationlist_findbyname ); |
dialogMessage = getString( stationlist_findbyname ); |
396 |
showDialog(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
397 |
|
|
451 |
MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); |
MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); |
452 |
//StationList.this.finish(); |
//StationList.this.finish(); |
453 |
return; |
return; |
454 |
|
case IDLE: |
455 |
|
Log.e("TrainInfo", "How did this happen ???"); |
456 |
|
dismissDialog(DLG_PROGRESS); // how did we get here ?? |
457 |
|
return; |
458 |
|
|
459 |
} |
} |
460 |
|
|
461 |
|
|
462 |
|
|
463 |
if (locationLookup.elapsedTime() >= GPS_TIMEOUT_MS) { |
if (locationLookup.elapsedTime() >= GPS_TIMEOUT_MS) { |
464 |
dismissDialog(DLG_PROGRESS); |
try { |
465 |
|
dismissDialog(DLG_PROGRESS); |
466 |
|
} catch (IllegalArgumentException ex) { |
467 |
|
// I get stacktraces that reports an exception is thrown here - |
468 |
|
// but i can not recreate the situation that causes said exception |
469 |
|
Log.e("TrainInfo", "Why the f*** is this exception thrown here ?? " + ex.getMessage() ); |
470 |
|
} |
471 |
|
|
472 |
locationLookup.stopSearch(); |
locationLookup.stopSearch(); |
473 |
|
|
480 |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
481 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
482 |
dialog.dismiss(); |
dialog.dismiss(); |
483 |
startLookup(); |
startNearestLookup(); |
484 |
|
|
485 |
} |
} |
486 |
}); |
}); |
487 |
builder.setNegativeButton( getString(generic_cancel), new DialogInterface.OnClickListener() { |
builder.setNegativeButton( getString(generic_cancel), new DialogInterface.OnClickListener() { |
488 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
489 |
dialog.dismiss(); |
dialog.dismiss(); |
490 |
|
StationList.this.finish(); // Close this Activity |
491 |
} |
} |
492 |
}); |
}); |
493 |
builder.show(); |
builder.show(); |
545 |
|
|
546 |
switch (method) { |
switch (method) { |
547 |
case ByLocation: |
case ByLocation: |
548 |
stations = stationProvider.lookupStations(loc); |
stations = stationProvider.lookupStationsByLocation(loc); |
549 |
break; |
break; |
550 |
case ByName: |
case ByName: |
551 |
stations = stationProvider.lookupStationsByName(name); |
stations = stationProvider.lookupStationsByName(name); |
598 |
runner = new Runnable() { |
runner = new Runnable() { |
599 |
@Override |
@Override |
600 |
public void run() { |
public void run() { |
601 |
startNameSearch( FindStationsTask.this.name ); |
startNameLookup( FindStationsTask.this.name ); |
602 |
} |
} |
603 |
}; |
}; |
604 |
break; |
break; |