39 |
import dk.thoerup.traininfo.provider.DepartureProvider; |
import dk.thoerup.traininfo.provider.DepartureProvider; |
40 |
import dk.thoerup.traininfo.provider.MetroProvider; |
import dk.thoerup.traininfo.provider.MetroProvider; |
41 |
import dk.thoerup.traininfo.provider.ProviderFactory; |
import dk.thoerup.traininfo.provider.ProviderFactory; |
42 |
|
|
43 |
|
import dk.thoerup.traininfo.util.FavoritesHelper; |
44 |
import dk.thoerup.traininfo.util.MessageBox; |
import dk.thoerup.traininfo.util.MessageBox; |
45 |
import dk.thoerup.traininfo.util.StationEntryCsv; |
import dk.thoerup.traininfo.util.StationEntryCsv; |
46 |
|
|
51 |
static final int MENU_NOTIFICATIONS = 101; |
static final int MENU_NOTIFICATIONS = 101; |
52 |
static final int MENU_METROMAP = 102; |
static final int MENU_METROMAP = 102; |
53 |
static final int MENU_TOGGLEDETAILS= 103; |
static final int MENU_TOGGLEDETAILS= 103; |
54 |
|
|
55 |
|
static final int MENU_FAVORITES_ADD = 104; |
56 |
|
static final int MENU_FAVORITES_REMOVE = 105; |
57 |
|
|
58 |
|
|
59 |
DepartureListAdapter adapter; |
DepartureListAdapter adapter; |
64 |
MetroProvider metro; |
MetroProvider metro; |
65 |
|
|
66 |
int selectedItemId; |
int selectedItemId; |
67 |
|
|
68 |
|
FavoritesHelper favorites; |
69 |
|
|
70 |
//DepartureBean currentDeparture; |
//DepartureBean currentDeparture; |
71 |
|
|
72 |
ProgressDialog pgDialog; |
ProgressDialog pgDialog; |
86 |
protected void onCreate(Bundle savedInstanceState) { |
protected void onCreate(Bundle savedInstanceState) { |
87 |
super.onCreate(savedInstanceState); |
super.onCreate(savedInstanceState); |
88 |
setContentView(R.layout.departurelist); |
setContentView(R.layout.departurelist); |
89 |
|
|
90 |
|
favorites = new FavoritesHelper(this); |
91 |
|
|
92 |
adapter = new DepartureListAdapter(this); |
adapter = new DepartureListAdapter(this); |
93 |
setListAdapter(adapter); |
setListAdapter(adapter); |
94 |
|
|
374 |
@Override |
@Override |
375 |
public boolean onPrepareOptionsMenu(Menu menu) { |
public boolean onPrepareOptionsMenu(Menu menu) { |
376 |
super.onPrepareOptionsMenu(menu); |
super.onPrepareOptionsMenu(menu); |
377 |
|
|
378 |
|
/////////////////////// |
379 |
|
|
380 |
MenuItem item = menu.findItem( MENU_NOTIFICATIONS ); |
MenuItem item = menu.findItem( MENU_NOTIFICATIONS ); |
381 |
boolean notifEnabled = hasNotifications(); |
boolean notifEnabled = hasNotifications(); |
382 |
item.setEnabled(notifEnabled); |
item.setEnabled(notifEnabled); |
383 |
|
|
384 |
|
////////////////////////// |
385 |
|
|
386 |
|
|
387 |
|
|
388 |
|
|
389 |
return true; |
return true; |
390 |
} |
} |
405 |
|
|
406 |
boolean notifEnabled = hasNotifications(); |
boolean notifEnabled = hasNotifications(); |
407 |
item.setEnabled(notifEnabled); |
item.setEnabled(notifEnabled); |
408 |
|
|
409 |
|
/////////////////////////////////////// |
410 |
|
if ( ! favorites.hasFavorite( this.station.getId() ) ) { |
411 |
|
item = menu.add(0, MENU_FAVORITES_ADD, 0, getString(dk.thoerup.traininfo.R.string.stationlist_addfavorite) ); |
412 |
|
} else { |
413 |
|
item = menu.add(0, MENU_FAVORITES_REMOVE, 0, getString(dk.thoerup.traininfo.R.string.stationlist_removefavorite) ); |
414 |
|
} |
415 |
|
item.setIcon(android.R.drawable.ic_menu_save); |
416 |
|
///////////////////////////// |
417 |
|
|
418 |
if (station.isMetro()) { |
if (station.isMetro()) { |
419 |
item = menu.add(0, MENU_METROMAP, 0, "Metro" ); //TODO:translate!?! |
item = menu.add(0, MENU_METROMAP, 0, "Metro" ); //TODO:translate!?! |
449 |
case MENU_TOGGLEDETAILS: |
case MENU_TOGGLEDETAILS: |
450 |
adapter.toggleShowDetails(); |
adapter.toggleShowDetails(); |
451 |
break; |
break; |
452 |
|
case MENU_FAVORITES_ADD: |
453 |
|
favorites.addFavorite( this.station.getId() ); |
454 |
|
Toast.makeText(this, getString(dk.thoerup.traininfo.R.string.stationlist_stationadded), Toast.LENGTH_SHORT).show(); |
455 |
|
break; |
456 |
|
case MENU_FAVORITES_REMOVE: |
457 |
|
favorites.removeFavorite( station.getId() ); |
458 |
|
Toast.makeText(this, getString(dk.thoerup.traininfo.R.string.stationlist_stationremoved), Toast.LENGTH_SHORT).show(); |
459 |
|
break; |
460 |
default: |
default: |
461 |
res = super.onOptionsItemSelected(item); |
res = super.onOptionsItemSelected(item); |
462 |
} |
} |