27 |
import android.widget.TableLayout; |
import android.widget.TableLayout; |
28 |
import android.widget.TableRow; |
import android.widget.TableRow; |
29 |
import android.widget.TextView; |
import android.widget.TextView; |
30 |
|
import dk.thoerup.android.traininfo.common.DepartureBean; |
31 |
|
import dk.thoerup.android.traininfo.common.DepartureEntry; |
32 |
|
import dk.thoerup.android.traininfo.common.MetroBean; |
33 |
|
import dk.thoerup.android.traininfo.common.MetroBean.MetroEntry; |
34 |
|
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
35 |
import dk.thoerup.traininfo.provider.DepartureProvider; |
import dk.thoerup.traininfo.provider.DepartureProvider; |
36 |
import dk.thoerup.traininfo.provider.MetroProvider; |
import dk.thoerup.traininfo.provider.MetroProvider; |
37 |
import dk.thoerup.traininfo.provider.ProviderFactory; |
import dk.thoerup.traininfo.provider.ProviderFactory; |
|
import dk.thoerup.traininfo.provider.MetroProvider.MetroBean; |
|
|
import dk.thoerup.traininfo.provider.MetroProvider.MetroEntry; |
|
38 |
import dk.thoerup.traininfo.util.MessageBox; |
import dk.thoerup.traininfo.util.MessageBox; |
39 |
|
|
40 |
public class DepartureList extends ListActivity { |
public class DepartureList extends ListActivity { |
42 |
public static final int DLG_PROGRESS = 1; |
public static final int DLG_PROGRESS = 1; |
43 |
static final int MENU_MAP = 100; |
static final int MENU_MAP = 100; |
44 |
static final int MENU_NOTIFICATIONS = 101; |
static final int MENU_NOTIFICATIONS = 101; |
45 |
|
static final int MENU_METROMAP= 102; |
46 |
|
|
47 |
|
|
48 |
DepartureListAdapter adapter; |
DepartureListAdapter adapter; |
60 |
DepartureFetcher fetcher; |
DepartureFetcher fetcher; |
61 |
MetroFetcher metroFetcher; |
MetroFetcher metroFetcher; |
62 |
|
|
63 |
StationBean station; |
StationEntry station; |
64 |
|
|
65 |
boolean arrival = false; |
boolean arrival = false; |
66 |
|
|
76 |
|
|
77 |
Intent launchedBy = getIntent(); |
Intent launchedBy = getIntent(); |
78 |
|
|
79 |
station = (StationBean) launchedBy.getSerializableExtra("stationbean"); |
station = (StationEntry) launchedBy.getSerializableExtra("stationbean"); |
80 |
|
|
81 |
((TextView) findViewById(R.id.stationName)).setText( station.getName() ); |
((TextView) findViewById(R.id.stationName)).setText( station.getName() ); |
82 |
|
|
134 |
|
|
135 |
// findViewById(R.id.header).setOnClickListener( mapLauncher ); |
// findViewById(R.id.header).setOnClickListener( mapLauncher ); |
136 |
|
|
137 |
int distance = station.getDistance(); |
int distance = station.getCalcdist(); |
138 |
if (distance != 0) { |
if (distance != 0) { |
139 |
NumberFormat format = NumberFormat.getNumberInstance(); |
NumberFormat format = NumberFormat.getNumberInstance(); |
140 |
format.setMaximumFractionDigits(1); |
format.setMaximumFractionDigits(1); |
155 |
|
|
156 |
metro = ProviderFactory.getMetroProvider(); |
metro = ProviderFactory.getMetroProvider(); |
157 |
|
|
158 |
if (station.isRegional() == false && station.isSTrain() == false) { |
if (station.isRegional() == false && station.isStrain() == false) { |
159 |
getListView().setVisibility( View.GONE ); |
getListView().setVisibility( View.GONE ); |
160 |
metroView.setVisibility( View.VISIBLE ); |
metroView.setVisibility( View.VISIBLE ); |
161 |
|
|
276 |
item.setIcon(android.R.drawable.ic_menu_mapmode); |
item.setIcon(android.R.drawable.ic_menu_mapmode); |
277 |
|
|
278 |
item = menu.add(0, MENU_NOTIFICATIONS, 0, getString(R.string.departurelist_notifications) ); |
item = menu.add(0, MENU_NOTIFICATIONS, 0, getString(R.string.departurelist_notifications) ); |
279 |
item.setIcon(android.R.drawable.ic_menu_info_details); |
item.setIcon(android.R.drawable.ic_menu_info_details); |
|
|
|
280 |
|
|
281 |
boolean notifEnabled = hasNotifications(); |
boolean notifEnabled = hasNotifications(); |
282 |
item.setEnabled(notifEnabled); |
item.setEnabled(notifEnabled); |
283 |
|
|
284 |
|
if (station.isMetro()) { |
285 |
|
item = menu.add(0, MENU_METROMAP, 0, "Metro" ); //TODO:translate!?! |
286 |
|
item.setIcon(android.R.drawable.ic_menu_mapmode); |
287 |
|
} |
288 |
|
|
289 |
|
|
290 |
return true; |
return true; |
291 |
} |
} |
305 |
startActivity(i); |
startActivity(i); |
306 |
res = true; |
res = true; |
307 |
break; |
break; |
308 |
|
case MENU_METROMAP: |
309 |
|
Intent metroMap = new Intent(this,dk.thoerup.traininfo.MetroMap.class); |
310 |
|
startActivity(metroMap); |
311 |
|
res = true; |
312 |
|
break; |
313 |
default: |
default: |
314 |
res = super.onOptionsItemSelected(item); |
res = super.onOptionsItemSelected(item); |
315 |
} |
} |
431 |
params.span = 2; |
params.span = 2; |
432 |
head.addView(h1, params); |
head.addView(h1, params); |
433 |
|
|
434 |
|
|
435 |
|
|
436 |
TextView h2 = new TextView(this); |
TextView h2 = new TextView(this); |
|
h2.setText("Om minutte"); |
|
437 |
h2.setTypeface( Typeface.defaultFromStyle(Typeface.BOLD)); |
h2.setTypeface( Typeface.defaultFromStyle(Typeface.BOLD)); |
438 |
head.addView(h2); |
h2.setText("Om minutter"); |
439 |
|
|
440 |
|
head.addView(h2,params); |
441 |
|
|
442 |
|
|
443 |
|
|
455 |
TextView v2 = new TextView(this); |
TextView v2 = new TextView(this); |
456 |
v2.setText( entry.destination ); |
v2.setText( entry.destination ); |
457 |
row.addView(v2); |
row.addView(v2); |
458 |
|
|
459 |
TextView v3 = new TextView(this); |
TextView v3 = new TextView(this); |
460 |
v3.setText( entry.minutes ); |
v3.setText( entry.minutes ); |
461 |
row.addView(v3); |
row.addView(v3); |