44 |
public static final int DLG_PROGRESS = 1; |
public static final int DLG_PROGRESS = 1; |
45 |
static final int MENU_MAP = 100; |
static final int MENU_MAP = 100; |
46 |
static final int MENU_NOTIFICATIONS = 101; |
static final int MENU_NOTIFICATIONS = 101; |
47 |
static final int MENU_METROMAP= 102; |
static final int MENU_METROMAP = 102; |
48 |
|
static final int MENU_TOGGLEDETAILS= 103; |
49 |
|
|
50 |
|
|
51 |
DepartureListAdapter adapter; |
DepartureListAdapter adapter; |
67 |
|
|
68 |
String trainType = "REGIONAL"; |
String trainType = "REGIONAL"; |
69 |
|
|
70 |
boolean arrival = false; |
boolean arrival = false; |
71 |
|
|
72 |
int commFailCounter = 0; |
int commFailCounter = 0; |
73 |
|
|
77 |
setContentView(R.layout.departurelist); |
setContentView(R.layout.departurelist); |
78 |
|
|
79 |
adapter = new DepartureListAdapter(this); |
adapter = new DepartureListAdapter(this); |
80 |
setListAdapter(adapter); |
setListAdapter(adapter); |
81 |
|
|
82 |
Intent launchedBy = getIntent(); |
Intent launchedBy = getIntent(); |
83 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
@Override |
342 |
|
public boolean onPrepareOptionsMenu(Menu menu) { |
343 |
|
super.onPrepareOptionsMenu(menu); |
344 |
|
|
345 |
|
MenuItem item = menu.findItem( MENU_NOTIFICATIONS ); |
346 |
|
boolean notifEnabled = hasNotifications(); |
347 |
|
item.setEnabled(notifEnabled); |
348 |
|
|
349 |
|
return true; |
350 |
|
} |
351 |
|
|
352 |
@Override |
@Override |
353 |
public boolean onCreateOptionsMenu(Menu menu) { |
public boolean onCreateOptionsMenu(Menu menu) { |
354 |
MenuItem item; |
MenuItem item; |
355 |
|
|
356 |
|
|
357 |
|
item = menu.add(0, MENU_TOGGLEDETAILS, 0, getString(R.string.departurelist_toggledetails)); |
358 |
|
item.setIcon(android.R.drawable.ic_menu_view); |
359 |
|
|
360 |
item = menu.add(0, MENU_MAP, 0, getString(R.string.departurelist_showonmap) ); |
item = menu.add(0, MENU_MAP, 0, getString(R.string.departurelist_showonmap) ); |
361 |
item.setIcon(android.R.drawable.ic_menu_mapmode); |
item.setIcon(android.R.drawable.ic_menu_mapmode); |
362 |
|
|
369 |
if (station.isMetro()) { |
if (station.isMetro()) { |
370 |
item = menu.add(0, MENU_METROMAP, 0, "Metro" ); //TODO:translate!?! |
item = menu.add(0, MENU_METROMAP, 0, "Metro" ); //TODO:translate!?! |
371 |
item.setIcon(android.R.drawable.ic_menu_mapmode); |
item.setIcon(android.R.drawable.ic_menu_mapmode); |
372 |
} |
} |
|
|
|
373 |
|
|
374 |
return true; |
return true; |
375 |
} |
} |
376 |
|
|
377 |
@Override |
@Override |
378 |
public boolean onOptionsItemSelected(MenuItem item) { |
public boolean onOptionsItemSelected(MenuItem item) { |
379 |
boolean res; |
boolean res = true; |
380 |
switch(item.getItemId()) { |
switch(item.getItemId()) { |
381 |
case MENU_MAP: |
case MENU_MAP: |
382 |
try { |
Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude() + "?z=16"); |
383 |
Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude() + "?z=16"); |
|
384 |
|
try { |
385 |
startActivity( new Intent(Intent.ACTION_VIEW, uri)); |
startActivity( new Intent(Intent.ACTION_VIEW, uri)); |
386 |
} catch (ActivityNotFoundException anfe) { |
} catch (ActivityNotFoundException anfe) { |
387 |
Toast.makeText(this, "Could not launch google maps", Toast.LENGTH_LONG).show(); |
Toast.makeText(this, "Could not launch google maps", Toast.LENGTH_LONG).show(); |
388 |
} |
} |
389 |
res = true; |
|
390 |
break; |
break; |
391 |
case MENU_NOTIFICATIONS: |
case MENU_NOTIFICATIONS: |
392 |
Intent i = new Intent(this,dk.thoerup.traininfo.NotificationList.class); |
Intent i = new Intent(this,dk.thoerup.traininfo.NotificationList.class); |
393 |
i.putExtra(NotificationList.EXTRA_NOTIFICATIONS, departures.notifications); |
i.putExtra(NotificationList.EXTRA_NOTIFICATIONS, departures.notifications); |
394 |
startActivity(i); |
startActivity(i); |
|
res = true; |
|
395 |
break; |
break; |
396 |
case MENU_METROMAP: |
case MENU_METROMAP: |
397 |
Intent metroMap = new Intent(this,dk.thoerup.traininfo.MetroMap.class); |
Intent metroMap = new Intent(this,dk.thoerup.traininfo.MetroMap.class); |
398 |
startActivity(metroMap); |
startActivity(metroMap); |
|
res = true; |
|
399 |
break; |
break; |
400 |
|
case MENU_TOGGLEDETAILS: |
401 |
|
adapter.toggleShowDetails(); |
402 |
|
break; |
403 |
default: |
default: |
404 |
res = super.onOptionsItemSelected(item); |
res = super.onOptionsItemSelected(item); |
405 |
} |
} |
458 |
DepartureList.this.getListView().setVisibility(View.VISIBLE); |
DepartureList.this.getListView().setVisibility(View.VISIBLE); |
459 |
|
|
460 |
|
|
461 |
// handle notification icon. |
// handle notification icon. |
462 |
if ( hasNotifications() ) { |
View notifIcon = findViewById(R.id.notifIcon); |
463 |
View notifIcon = findViewById(R.id.notifIcon); |
if ( hasNotifications() ) { |
464 |
notifIcon.setVisibility(View.VISIBLE); |
notifIcon.setVisibility(View.VISIBLE); |
465 |
notifIcon.setClickable(true); |
notifIcon.setClickable(true); |
466 |
notifIcon.setOnClickListener( new View.OnClickListener() { |
notifIcon.setOnClickListener( new View.OnClickListener() { |
471 |
startActivity(i); |
startActivity(i); |
472 |
} |
} |
473 |
}); |
}); |
474 |
} |
} else { |
475 |
|
notifIcon.setVisibility(View.INVISIBLE); |
476 |
|
} |
477 |
|
|
478 |
if (departures.entries.size() == 0) { |
if (departures.entries.size() == 0) { |
479 |
int msgId = (arrival==false) ? R.string.departurelist_nodepartures : R.string.departurelist_noarrivals; |
int msgId = (arrival==false) ? R.string.departurelist_nodepartures : R.string.departurelist_noarrivals; |