6 |
import static dk.thoerup.traininfo.R.string.timetablelist_fetchdata; |
import static dk.thoerup.traininfo.R.string.timetablelist_fetchdata; |
7 |
import static dk.thoerup.traininfo.R.string.timetablelist_fetcherror; |
import static dk.thoerup.traininfo.R.string.timetablelist_fetcherror; |
8 |
import static dk.thoerup.traininfo.R.string.timetablelist_nodata; |
import static dk.thoerup.traininfo.R.string.timetablelist_nodata; |
9 |
|
|
10 |
|
import java.util.regex.Pattern; |
11 |
|
|
12 |
import android.app.AlertDialog; |
import android.app.AlertDialog; |
13 |
import android.app.Dialog; |
import android.app.Dialog; |
14 |
import android.app.ListActivity; |
import android.app.ListActivity; |
22 |
import android.widget.ListView; |
import android.widget.ListView; |
23 |
import android.widget.TextView; |
import android.widget.TextView; |
24 |
import dk.thoerup.android.traininfo.common.DepartureEntry; |
import dk.thoerup.android.traininfo.common.DepartureEntry; |
25 |
|
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
26 |
import dk.thoerup.android.traininfo.common.TimetableBean; |
import dk.thoerup.android.traininfo.common.TimetableBean; |
27 |
import dk.thoerup.android.traininfo.common.TimetableEntry; |
import dk.thoerup.android.traininfo.common.TimetableEntry; |
|
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
|
28 |
import dk.thoerup.traininfo.provider.ProviderFactory; |
import dk.thoerup.traininfo.provider.ProviderFactory; |
29 |
import dk.thoerup.traininfo.provider.TimetableProvider; |
import dk.thoerup.traininfo.provider.TimetableProvider; |
30 |
import dk.thoerup.traininfo.util.MessageBox; |
import dk.thoerup.traininfo.util.MessageBox; |
40 |
|
|
41 |
TimetableProvider provider; |
TimetableProvider provider; |
42 |
|
|
43 |
@SuppressWarnings("unchecked") |
|
44 |
@Override |
@Override |
45 |
protected void onCreate(Bundle savedInstanceState) { |
protected void onCreate(Bundle savedInstanceState) { |
46 |
super.onCreate(savedInstanceState); |
super.onCreate(savedInstanceState); |
57 |
departure = (DepartureEntry) launchedBy.getSerializableExtra("departure"); |
departure = (DepartureEntry) launchedBy.getSerializableExtra("departure"); |
58 |
|
|
59 |
((TextView)findViewById(R.id.Train)).setText(departure.getTrainNumber()); |
((TextView)findViewById(R.id.Train)).setText(departure.getTrainNumber()); |
60 |
((TextView)findViewById(R.id.Status)).setText(departure.getStatus()); |
|
61 |
((TextView)findViewById(R.id.Location)).setText(departure.getLocation()); |
((TextView)findViewById(R.id.Location)).setText(departure.getLocation()); |
|
((TextView)findViewById(R.id.Note)).setText(departure.getNote()); |
|
62 |
((TextView)findViewById(R.id.Updated)).setText( getLastUpdateString( departure.getUpdated() )); |
((TextView)findViewById(R.id.Updated)).setText( getLastUpdateString( departure.getUpdated() )); |
63 |
|
|
64 |
|
String status = departure.getStatus() != null ? departure.getStatus() : ""; |
65 |
|
if ( Pattern.matches("[0-9]+.+min", status) ) { |
66 |
|
status += " " + this.getString(R.string.departurebean_delayed); |
67 |
|
} |
68 |
|
String note = departure.getNote() != null ? departure.getNote() : ""; |
69 |
|
note = note.replace("Aflyst", this.getString(R.string.timetablelist_cancelled) ); |
70 |
|
note = note.replace("Kører kun til", this.getString(R.string.timetablelist_goesonlyto) ); |
71 |
|
note = note.replace("Afgår fra", this.getString(R.string.timetablelist_startsat) ); |
72 |
|
note = note.replace("Erstattet af", this.getString(R.string.timetablelist_replacedby) ); |
73 |
|
note = note.replace("Eksterne forhold", this.getString(R.string.timetablelist_externalconditions) ); |
74 |
|
note = note.replace("Teknisk fejl på et signal", this.getString(R.string.timetablelist_technicalerroronsignal) ); |
75 |
|
note = note.replace("Materielforhold", this.getString(R.string.timetablelist_equipmentrelated) ); |
76 |
|
note = note.replace("Passagerforhold", this.getString(R.string.timetablelist_passengerrelated) ); |
77 |
|
note = note.replace("Forventet rettidig afgang", this.getString(R.string.timetablelist_expectedtimelydeparture) ); |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
((TextView)findViewById(R.id.Status)).setText(status); |
82 |
|
((TextView)findViewById(R.id.Note)).setText(note); |
83 |
|
|
84 |
|
|
85 |
ProviderFactory.purgeOldEntries(); //cleanup before fetching more data |
ProviderFactory.purgeOldEntries(); //cleanup before fetching more data |
86 |
|
|
186 |
super.onPostExecute(result); |
super.onPostExecute(result); |
187 |
dismissDialog(DLG_PROGRESS); |
dismissDialog(DLG_PROGRESS); |
188 |
|
|
189 |
|
//TODO: differentiate between a communication error and a downed bane.dk site |
190 |
if (timetables != null) { |
if (timetables != null) { |
191 |
commFailCounter = 0; |
commFailCounter = 0; |
192 |
TimetableList.this.getListView().invalidateViews(); |
TimetableList.this.getListView().invalidateViews(); |