1 |
package dk.thoerup.traininfo; |
package dk.thoerup.traininfo; |
2 |
|
|
3 |
import java.util.ArrayList; |
import static dk.thoerup.traininfo.R.string.app_name; |
4 |
import java.util.List; |
import static dk.thoerup.traininfo.R.string.generic_cancel; |
5 |
|
import static dk.thoerup.traininfo.R.string.generic_retry; |
6 |
|
import static dk.thoerup.traininfo.R.string.generic_search; |
7 |
|
import static dk.thoerup.traininfo.R.string.stationlist_accuracy; |
8 |
|
import static dk.thoerup.traininfo.R.string.stationlist_addfavorite; |
9 |
|
import static dk.thoerup.traininfo.R.string.stationlist_favorites; |
10 |
|
import static dk.thoerup.traininfo.R.string.stationlist_fetcherror; |
11 |
|
import static dk.thoerup.traininfo.R.string.stationlist_findbyname; |
12 |
|
import static dk.thoerup.traininfo.R.string.stationlist_findingnearby; |
13 |
|
import static dk.thoerup.traininfo.R.string.stationlist_gpsinfo; |
14 |
|
import static dk.thoerup.traininfo.R.string.stationlist_gpstimeout; |
15 |
|
import static dk.thoerup.traininfo.R.string.stationlist_latitude; |
16 |
|
import static dk.thoerup.traininfo.R.string.stationlist_loadfavorites; |
17 |
|
import static dk.thoerup.traininfo.R.string.stationlist_locationinfo; |
18 |
|
import static dk.thoerup.traininfo.R.string.stationlist_longitude; |
19 |
|
import static dk.thoerup.traininfo.R.string.stationlist_nearbystations; |
20 |
|
import static dk.thoerup.traininfo.R.string.stationlist_nofavorites; |
21 |
|
import static dk.thoerup.traininfo.R.string.stationlist_nolocation; |
22 |
|
import static dk.thoerup.traininfo.R.string.stationlist_nolocationprovider; |
23 |
|
import static dk.thoerup.traininfo.R.string.stationlist_nostations; |
24 |
|
import static dk.thoerup.traininfo.R.string.stationlist_obtainedby; |
25 |
|
import static dk.thoerup.traininfo.R.string.stationlist_removefavorite; |
26 |
|
import static dk.thoerup.traininfo.R.string.stationlist_search; |
27 |
|
import static dk.thoerup.traininfo.R.string.stationlist_stationadded; |
28 |
|
import static dk.thoerup.traininfo.R.string.stationlist_stationmap; |
29 |
|
import static dk.thoerup.traininfo.R.string.stationlist_stationremoved; |
30 |
|
import static dk.thoerup.traininfo.R.string.stationlist_stationsearch; |
31 |
|
import static dk.thoerup.traininfo.R.string.stationlist_twocharmin; |
32 |
|
import static dk.thoerup.traininfo.R.string.stationlist_waitforlocation; |
33 |
|
import static dk.thoerup.traininfo.R.string.stationlist_satellitecount; |
34 |
|
|
35 |
|
import java.util.ArrayList; |
36 |
|
|
37 |
import android.app.Activity; |
import android.app.Activity; |
38 |
import android.app.AlertDialog; |
import android.app.AlertDialog; |
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; |
|
|
|
|
import android.util.Log; |
|
51 |
import android.view.ContextMenu; |
import android.view.ContextMenu; |
52 |
import android.view.LayoutInflater; |
import android.view.LayoutInflater; |
53 |
import android.view.Menu; |
import android.view.Menu; |
59 |
import android.widget.EditText; |
import android.widget.EditText; |
60 |
import android.widget.ListView; |
import android.widget.ListView; |
61 |
import android.widget.Toast; |
import android.widget.Toast; |
62 |
|
import dk.thoerup.android.traininfo.common.StationBean; |
63 |
|
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
64 |
import dk.thoerup.traininfo.provider.ProviderFactory; |
import dk.thoerup.traininfo.provider.ProviderFactory; |
65 |
import dk.thoerup.traininfo.provider.StationProvider; |
import dk.thoerup.traininfo.provider.StationProvider; |
66 |
import dk.thoerup.traininfo.stationmap.GeoPair; |
import dk.thoerup.traininfo.stationmap.GeoPair; |
68 |
import dk.thoerup.traininfo.util.IntSet; |
import dk.thoerup.traininfo.util.IntSet; |
69 |
import dk.thoerup.traininfo.util.MessageBox; |
import dk.thoerup.traininfo.util.MessageBox; |
70 |
|
|
|
import static dk.thoerup.traininfo.R.string.*; |
|
|
|
|
71 |
public class StationList extends ListActivity { |
public class StationList extends ListActivity { |
72 |
public static final int GOTLOCATION = 1001; |
|
73 |
public static final int GOTSTATIONLIST = 1002; |
|
|
public static final int NOPROVIDER = 1003; |
|
|
public static final int LOCATIONFIXTIMEOUT = 1004; |
|
74 |
|
|
75 |
public static final int OPTIONS_MAP = 2003; |
public static final int OPTIONS_MAP = 2003; |
76 |
public static final int OPTIONS_GPSINFO = 2004; |
public static final int OPTIONS_GPSINFO = 2004; |
|
|
|
|
|
|
|
|
|
77 |
|
|
78 |
public static final int DLG_PROGRESS = 3001; |
public static final int DLG_PROGRESS = 3001; |
79 |
public static final int DLG_STATIONNAME = 3002; |
public static final int DLG_STATIONNAME = 3002; |
80 |
|
|
81 |
|
|
82 |
|
public static final int GPS_TIMEOUT_MS = 15000; //how long are we willing to wait for gps fix -in milliseconds |
83 |
|
|
84 |
|
|
85 |
static enum LookupMethod { |
static enum LookupMethod { |
86 |
ByLocation, |
ByLocation, |
87 |
ByName, |
ByName, |
96 |
FindStationsTask findStationsTask; |
FindStationsTask findStationsTask; |
97 |
StationsFetchedHandler stationsFetched = new StationsFetchedHandler(); |
StationsFetchedHandler stationsFetched = new StationsFetchedHandler(); |
98 |
|
|
99 |
GeoPair location = new GeoPair(); |
//GeoPair location = new GeoPair(); |
100 |
|
|
101 |
boolean isLaunchedforShortcut; |
boolean isLaunchedforShortcut; |
102 |
boolean isRunning = false; |
|
103 |
List<StationBean> stations = new ArrayList<StationBean>(); |
StationBean stations = new StationBean(); |
104 |
|
|
105 |
StationProvider stationProvider = ProviderFactory.getStationProvider(); |
StationProvider stationProvider = ProviderFactory.getStationProvider(); |
106 |
|
|
111 |
|
|
112 |
WelcomeScreen.ListType listType; |
WelcomeScreen.ListType listType; |
113 |
SharedPreferences prefs; |
SharedPreferences prefs; |
114 |
|
|
115 |
/////////////////////////////////////////////////////////////////////////////////////////// |
/////////////////////////////////////////////////////////////////////////////////////////// |
116 |
//Activity call backs |
//Activity call backs |
117 |
|
|
118 |
@SuppressWarnings("unchecked") |
|
119 |
@Override |
@Override |
120 |
public void onCreate(Bundle savedInstanceState) { |
public void onCreate(Bundle savedInstanceState) { |
121 |
super.onCreate(savedInstanceState); |
super.onCreate(savedInstanceState); |
128 |
ListView lv = getListView(); |
ListView lv = getListView(); |
129 |
lv.setOnCreateContextMenuListener(contextMenu); |
lv.setOnCreateContextMenuListener(contextMenu); |
130 |
|
|
131 |
locationLookup = new LocationLookup(this, stationsFetched); |
locationLookup = new LocationLookup(this); |
132 |
|
|
133 |
|
|
134 |
prefs = getSharedPreferences("TrainStation", 0); |
prefs = getSharedPreferences("TrainStation", 0); |
142 |
|
|
143 |
isLaunchedforShortcut = getIntent().getBooleanExtra("shortcut", false); |
isLaunchedforShortcut = getIntent().getBooleanExtra("shortcut", false); |
144 |
|
|
145 |
|
ProviderFactory.purgeOldEntries(); //cleanup before fetching more data |
146 |
|
|
147 |
if (savedInstanceState == null) { |
if (savedInstanceState == null) { |
148 |
|
|
149 |
|
|
151 |
case ListNearest: |
case ListNearest: |
152 |
startLookup(); |
startLookup(); |
153 |
break; |
break; |
154 |
case ListSearch: |
case ListSearch: |
155 |
this.showDialogSafe(DLG_STATIONNAME); |
showDialog(DLG_STATIONNAME); |
156 |
break; |
break; |
157 |
case ListFavorites: |
case ListFavorites: |
158 |
startFavoriteLookup(); |
startFavoriteLookup(); |
162 |
} |
} |
163 |
|
|
164 |
} else { |
} else { |
165 |
stations = (ArrayList<StationBean>) savedInstanceState.getSerializable("stations"); |
stations = (StationBean) savedInstanceState.getSerializable("stations"); |
166 |
adapter.setStations(stations); |
adapter.setStations(stations); |
|
location = (GeoPair) savedInstanceState.getSerializable("location"); |
|
167 |
} |
} |
168 |
|
|
169 |
} |
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
@Override |
177 |
|
protected void onDestroy() { |
178 |
|
super.onDestroy(); |
179 |
|
|
180 |
|
|
181 |
|
if (locationLookup != null) { |
182 |
|
locationLookup.stopSearch(); |
183 |
|
} |
184 |
|
if (findStationsTask != null) { |
185 |
|
findStationsTask.cancel(true); |
186 |
|
} |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
protected void setTitle() { |
protected void setTitle() { |
191 |
String dialogTitle = getResources().getString(app_name); |
String dialogTitle = getResources().getString(app_name); |
192 |
switch (listType) { |
switch (listType) { |
207 |
|
|
208 |
} |
} |
209 |
|
|
|
|
|
|
/* these 3 dialogs helper functions are very rude and ugly hack |
|
|
* to remove these auto-reported exceptions |
|
|
* - android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@436aaef8 is not valid; is your activity running? |
|
|
* - java.lang.IllegalArgumentException: View not attached to window manager |
|
|
*/ |
|
|
|
|
|
public void showDialogSafe(int id) { |
|
|
try { |
|
|
showDialog(id); |
|
|
} catch (Exception e) { |
|
|
Log.e("StationList", "showDialog failed", e); |
|
|
} |
|
|
} |
|
|
|
|
|
public void dismissDialogSafe(int id) { |
|
|
try { |
|
|
dismissDialog(id); |
|
|
} catch (Exception e) { |
|
|
Log.e("StationList", "dismissDialog failed", e); |
|
|
} |
|
|
} |
|
|
public void dismissDialogSafe(Dialog dlg) { |
|
|
try { |
|
|
dlg.dismiss(); |
|
|
} catch (Exception e) { |
|
|
Log.e("StationList", "dismissDialog failed", e); |
|
|
} |
|
|
} |
|
|
|
|
|
public void builderShowSafe(AlertDialog.Builder builder) { |
|
|
try { |
|
|
builder.show(); |
|
|
} catch (Exception e) { |
|
|
Log.e("StationList", "builder.show() failed", e); |
|
|
} |
|
210 |
|
|
|
} |
|
|
/* EOF rude and ugly dialog hack */ |
|
|
|
|
|
|
|
211 |
|
|
212 |
@Override |
@Override |
213 |
public void onSaveInstanceState(Bundle outState) |
public void onSaveInstanceState(Bundle outState) |
214 |
{ |
{ |
215 |
if (dialog != null && dialog.isShowing()) |
if (dialog != null && dialog.isShowing()) |
216 |
dialog.dismiss(); |
dialog.dismiss(); |
217 |
outState.putSerializable("stations", (ArrayList<StationBean>) stations); |
outState.putSerializable("stations", (StationBean) stations); |
|
outState.putSerializable("location", location); |
|
218 |
|
|
219 |
} |
} |
220 |
|
|
244 |
Intent intent = new Intent(this,StationMapView.class); |
Intent intent = new Intent(this,StationMapView.class); |
245 |
|
|
246 |
ArrayList<GeoPair> stationPoints = new ArrayList<GeoPair>(); |
ArrayList<GeoPair> stationPoints = new ArrayList<GeoPair>(); |
247 |
for (StationBean st : stations ) { |
for (StationEntry st : stations.entries ) { |
248 |
stationPoints.add( new GeoPair(st.getLatitude(), st.getLongitude(), st.getName()) ); |
stationPoints.add( new GeoPair(st.getLatitude(), st.getLongitude(), st.getName()) ); |
249 |
} |
} |
250 |
|
|
265 |
message.append( getString(stationlist_nolocation) ); |
message.append( getString(stationlist_nolocation) ); |
266 |
} |
} |
267 |
|
|
268 |
MessageBox.showMessage(this, message.toString()); |
MessageBox.showMessage(this, message.toString(), false); |
269 |
break; |
break; |
270 |
default: |
default: |
271 |
retval = super.onOptionsItemSelected(item); |
retval = super.onOptionsItemSelected(item); |
363 |
protected void onListItemClick(ListView l, View v, int position, long id) { |
protected void onListItemClick(ListView l, View v, int position, long id) { |
364 |
super.onListItemClick(l, v, position, id); |
super.onListItemClick(l, v, position, id); |
365 |
|
|
366 |
StationBean station = stations.get(position); |
StationEntry station = stations.entries.get(position); |
367 |
|
|
368 |
if (isLaunchedforShortcut == true) { |
if (isLaunchedforShortcut == true) { |
369 |
Intent i = new Intent(); |
Intent i = new Intent(); |
381 |
// |
// |
382 |
|
|
383 |
public void startLookup() { |
public void startLookup() { |
|
isRunning = true; |
|
384 |
dialogMessage = getString( stationlist_waitforlocation ); |
dialogMessage = getString( stationlist_waitforlocation ); |
385 |
showDialogSafe(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
386 |
|
|
387 |
locationLookup.locateStations(); |
locationLookup.locateStations(); |
388 |
stationsFetched.sendEmptyMessageDelayed(LOCATIONFIXTIMEOUT, 20000); |
stationsFetched.sendEmptyMessageDelayed(0, 500); |
389 |
} |
} |
390 |
|
|
391 |
void startNameSearch(String name) { |
void startNameSearch(String name) { |
392 |
dialogMessage = getString( stationlist_findbyname ); |
dialogMessage = getString( stationlist_findbyname ); |
393 |
showDialogSafe(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
394 |
|
|
395 |
findStationsTask = new FindStationsTask(); |
findStationsTask = new FindStationsTask(); |
396 |
findStationsTask.searchByName(name); |
findStationsTask.searchByName(name); |
402 |
|
|
403 |
if (favorites.size() > 0) { |
if (favorites.size() > 0) { |
404 |
dialogMessage = getString( stationlist_loadfavorites ); |
dialogMessage = getString( stationlist_loadfavorites ); |
405 |
showDialogSafe(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
406 |
|
|
407 |
findStationsTask = new FindStationsTask(); |
findStationsTask = new FindStationsTask(); |
408 |
findStationsTask.searchByIds( favorites.toString() ); |
findStationsTask.searchByIds( favorites.toString() ); |
417 |
void startLocatorTask() |
void startLocatorTask() |
418 |
{ |
{ |
419 |
dialogMessage = getString( stationlist_findingnearby ); |
dialogMessage = getString( stationlist_findingnearby ); |
420 |
showDialogSafe(DLG_PROGRESS); |
showDialog(DLG_PROGRESS); |
421 |
|
|
422 |
findStationsTask = new FindStationsTask(); |
findStationsTask = new FindStationsTask(); |
423 |
findStationsTask.searchByLocation( locationLookup.getLocation() ); |
findStationsTask.searchByLocation( locationLookup.getLocation() ); |
432 |
@Override |
@Override |
433 |
public void handleMessage(Message msg) { |
public void handleMessage(Message msg) { |
434 |
|
|
435 |
switch (msg.what) { |
LocationLookup.LookupStates state = locationLookup.getState(); |
436 |
|
|
437 |
|
|
438 |
|
switch (state) { |
439 |
case GOTLOCATION: |
case GOTLOCATION: |
440 |
dismissDialogSafe(DLG_PROGRESS); |
dismissDialog(DLG_PROGRESS); |
441 |
|
|
442 |
startLocatorTask(); |
startLocatorTask(); |
443 |
location = GeoPair.fromLocation( locationLookup.getLocation() ); |
|
444 |
|
return; |
|
break; |
|
445 |
|
|
446 |
case NOPROVIDER: |
case NOPROVIDER: |
447 |
dismissDialogSafe(DLG_PROGRESS); |
dismissDialog(DLG_PROGRESS); |
448 |
MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider) ); |
MessageBox.showMessage(StationList.this, getString(stationlist_nolocationprovider), true ); |
449 |
break; |
//StationList.this.finish(); |
450 |
case LOCATIONFIXTIMEOUT: |
return; |
451 |
if (isRunning) { |
} |
452 |
locationLookup.stopSearch(); |
|
453 |
if (locationLookup.hasLocation()) { |
|
454 |
stationsFetched.sendEmptyMessage( GOTLOCATION ); |
|
455 |
} else { |
if (locationLookup.elapsedTime() >= GPS_TIMEOUT_MS) { |
456 |
dismissDialogSafe(DLG_PROGRESS); |
dismissDialog(DLG_PROGRESS); |
457 |
|
|
458 |
AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this); |
locationLookup.stopSearch(); |
459 |
builder.setMessage( getString( stationlist_gpstimeout) ); |
|
460 |
builder.setCancelable(true); |
if (locationLookup.hasLocation()) { |
461 |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
startLocatorTask(); |
462 |
public void onClick(DialogInterface dialog, int id) { |
} else { |
463 |
dialog.dismiss(); |
AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this); |
464 |
startLookup(); |
builder.setMessage( getString( stationlist_gpstimeout) ); |
465 |
|
builder.setCancelable(true); |
466 |
} |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
467 |
}); |
public void onClick(DialogInterface dialog, int id) { |
468 |
builder.setNegativeButton( getString(generic_cancel), new DialogInterface.OnClickListener() { |
dialog.dismiss(); |
469 |
public void onClick(DialogInterface dialog, int id) { |
startLookup(); |
470 |
dialog.dismiss(); |
|
471 |
} |
} |
472 |
}); |
}); |
473 |
builderShowSafe(builder); // builder.show() |
builder.setNegativeButton( getString(generic_cancel), new DialogInterface.OnClickListener() { |
474 |
|
public void onClick(DialogInterface dialog, int id) { |
475 |
|
dialog.dismiss(); |
476 |
|
} |
477 |
|
}); |
478 |
|
builder.show(); |
479 |
|
|
|
} |
|
480 |
} |
} |
481 |
break; |
} else { |
482 |
|
if (locationLookup.hasGps()) { |
483 |
|
int count = locationLookup.getSatCount(); |
484 |
|
String dialogMessage = getString( stationlist_waitforlocation ) + "\n" + getString( stationlist_satellitecount ) + ": " + count; |
485 |
|
dialog.setMessage( dialogMessage ); |
486 |
|
} |
487 |
|
this.sendEmptyMessageDelayed(0, 500); |
488 |
} |
} |
489 |
isRunning = false; |
|
490 |
} |
} |
491 |
}; |
} |
492 |
|
|
493 |
|
|
494 |
|
|
495 |
|
|
496 |
class FindStationsTask extends AsyncTask<Void,Void,Void> { |
class FindStationsTask extends AsyncTask<Void,Void,Void> { |
497 |
|
|
498 |
LookupMethod method = LookupMethod.MethodNone; |
LookupMethod method = LookupMethod.MethodNone; |
|
boolean success; |
|
499 |
String name; |
String name; |
500 |
Location loc; |
Location loc; |
501 |
String ids; |
String ids; |
530 |
|
|
531 |
switch (method) { |
switch (method) { |
532 |
case ByLocation: |
case ByLocation: |
533 |
success = stationProvider.lookupStations(loc); |
stations = stationProvider.lookupStations(loc); |
534 |
break; |
break; |
535 |
case ByName: |
case ByName: |
536 |
success = stationProvider.lookupStationsByName(name); |
stations = stationProvider.lookupStationsByName(name); |
537 |
break; |
break; |
538 |
case ByList: |
case ByList: |
539 |
success = stationProvider.lookupStationsByIds(ids); |
stations = stationProvider.lookupStationsByIds(ids); |
540 |
break; |
break; |
541 |
default: |
default: |
542 |
success = false; // not possible |
stations = null; // not possible |
543 |
} |
} |
544 |
|
|
545 |
|
|
549 |
@Override |
@Override |
550 |
protected void onPostExecute(Void result) { |
protected void onPostExecute(Void result) { |
551 |
super.onPostExecute(result); |
super.onPostExecute(result); |
552 |
dismissDialogSafe(dialog); |
dialog.dismiss(); |
553 |
|
|
554 |
|
|
555 |
if (success) { |
if (stations != null) { |
556 |
if (stationProvider.getStations().size() == 0) { |
if (stations.entries.size() == 0) { |
557 |
showMessageAndClose(getString(stationlist_nostations)); |
showMessageAndClose(getString(stationlist_nostations)); |
558 |
} |
} |
559 |
stations = stationProvider.getStations(); |
|
560 |
|
StationList.this.getListView().invalidateViews(); |
561 |
adapter.setStations( stations ); |
adapter.setStations( stations ); |
562 |
|
|
563 |
|
|
564 |
} else { //communication or parse errors |
} else { //communication or parse errors |
565 |
AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this); |
AlertDialog.Builder builder = new AlertDialog.Builder(StationList.this); |
566 |
builder.setMessage(getString(stationlist_nearbyerror)); |
builder.setMessage(getString(stationlist_fetcherror)); |
567 |
builder.setCancelable(true); |
builder.setCancelable(true); |
568 |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
569 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
603 |
builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { |
builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { |
604 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
605 |
dialog.dismiss(); |
dialog.dismiss(); |
606 |
|
StationList.this.finish(); |
607 |
} |
} |
608 |
}); |
}); |
609 |
|
|
610 |
builderShowSafe(builder); // builder.show() |
builder.show(); |
611 |
} |
} |
612 |
} |
} |
613 |
} |
} |
625 |
|
|
626 |
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; |
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; |
627 |
selectedPosition = info.position; |
selectedPosition = info.position; |
628 |
int stationID = stations.get(selectedPosition).getId(); |
int stationID = stations.entries.get(selectedPosition).getId(); |
629 |
|
|
630 |
if (!favorites.contains(stationID)) { |
if (!favorites.contains(stationID)) { |
631 |
menu.add(0, FAVORITES_ADD, 0, getString(stationlist_addfavorite) ); |
menu.add(0, FAVORITES_ADD, 0, getString(stationlist_addfavorite) ); |
636 |
} |
} |
637 |
|
|
638 |
public void onContextItemSelected(MenuItem item) { |
public void onContextItemSelected(MenuItem item) { |
639 |
StationBean sb = stations.get(selectedPosition); |
StationEntry sb = stations.entries.get(selectedPosition); |
640 |
|
|
641 |
int stationID = sb.getId(); |
int stationID = sb.getId(); |
642 |
if (item.getItemId() == FAVORITES_ADD) { |
if (item.getItemId() == FAVORITES_ADD) { |
649 |
|
|
650 |
|
|
651 |
if (listType.equals( WelcomeScreen.ListType.ListFavorites) ) { |
if (listType.equals( WelcomeScreen.ListType.ListFavorites) ) { |
652 |
stations.remove(selectedPosition); |
stations.entries.remove(selectedPosition); |
653 |
adapter.notifyDataSetChanged(); |
adapter.notifyDataSetChanged(); |
654 |
} |
} |
655 |
} |
} |