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); |
325 |
dialog.dismiss(); |
dialog.dismiss(); |
326 |
String search = et.getText().toString().trim(); |
String search = et.getText().toString().trim(); |
327 |
if (search.length() >= 2) { |
if (search.length() >= 2) { |
328 |
startNameSearch(search); |
startNameLookup(search); |
329 |
} else { |
} else { |
330 |
showMessageAndClose( getString(stationlist_twocharmin) ); |
showMessageAndClose( getString(stationlist_twocharmin) ); |
331 |
} |
} |
381 |
///////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////// |
382 |
// |
// |
383 |
|
|
384 |
public void startLookup() { |
public void startNearestLookup() { |
385 |
dialogMessage = getString( stationlist_waitforlocation ); |
dialogMessage = getString( stationlist_waitforlocation ); |
386 |
showDialog(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
387 |
|
|
389 |
stationsFetched.sendEmptyMessageDelayed(0, 500); |
stationsFetched.sendEmptyMessageDelayed(0, 500); |
390 |
} |
} |
391 |
|
|
392 |
void startNameSearch(String name) { |
void startNameLookup(String name) { |
393 |
dialogMessage = getString( stationlist_findbyname ); |
dialogMessage = getString( stationlist_findbyname ); |
394 |
showDialog(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
395 |
|
|
449 |
MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); |
MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); |
450 |
//StationList.this.finish(); |
//StationList.this.finish(); |
451 |
return; |
return; |
452 |
|
case IDLE: |
453 |
|
Log.e("TrainInfo", "How did this happen ???"); |
454 |
|
dismissDialog(DLG_PROGRESS); // how did we get here ?? |
455 |
|
return; |
456 |
|
|
457 |
} |
} |
458 |
|
|
459 |
|
|
460 |
|
|
461 |
if (locationLookup.elapsedTime() >= GPS_TIMEOUT_MS) { |
if (locationLookup.elapsedTime() >= GPS_TIMEOUT_MS) { |
462 |
dismissDialog(DLG_PROGRESS); |
try { |
463 |
|
dismissDialog(DLG_PROGRESS); |
464 |
|
} catch (IllegalArgumentException ex) { |
465 |
|
// I get stacktraces that reports an exception is thrown here - |
466 |
|
// but i can not recreate the situation that causes said exception |
467 |
|
Log.e("TrainInfo", "Why the f*** is this exception thrown here ?? " + ex.getMessage() ); |
468 |
|
} |
469 |
|
|
470 |
locationLookup.stopSearch(); |
locationLookup.stopSearch(); |
471 |
|
|
478 |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
479 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
480 |
dialog.dismiss(); |
dialog.dismiss(); |
481 |
startLookup(); |
startNearestLookup(); |
482 |
|
|
483 |
} |
} |
484 |
}); |
}); |
485 |
builder.setNegativeButton( getString(generic_cancel), new DialogInterface.OnClickListener() { |
builder.setNegativeButton( getString(generic_cancel), new DialogInterface.OnClickListener() { |
486 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
487 |
dialog.dismiss(); |
dialog.dismiss(); |
488 |
|
StationList.this.finish(); // Close this Activity |
489 |
} |
} |
490 |
}); |
}); |
491 |
builder.show(); |
builder.show(); |
543 |
|
|
544 |
switch (method) { |
switch (method) { |
545 |
case ByLocation: |
case ByLocation: |
546 |
stations = stationProvider.lookupStations(loc); |
stations = stationProvider.lookupStationsByLocation(loc); |
547 |
break; |
break; |
548 |
case ByName: |
case ByName: |
549 |
stations = stationProvider.lookupStationsByName(name); |
stations = stationProvider.lookupStationsByName(name); |
596 |
runner = new Runnable() { |
runner = new Runnable() { |
597 |
@Override |
@Override |
598 |
public void run() { |
public void run() { |
599 |
startNameSearch( FindStationsTask.this.name ); |
startNameLookup( FindStationsTask.this.name ); |
600 |
} |
} |
601 |
}; |
}; |
602 |
break; |
break; |