--- android/TrainInfo/src/dk/thoerup/traininfo/TimetableList.java 2010/09/16 15:32:42 1066 +++ android/TrainInfo/src/dk/thoerup/traininfo/TimetableList.java 2011/04/05 15:05:16 1266 @@ -6,6 +6,9 @@ import static dk.thoerup.traininfo.R.string.timetablelist_fetchdata; import static dk.thoerup.traininfo.R.string.timetablelist_fetcherror; import static dk.thoerup.traininfo.R.string.timetablelist_nodata; + +import java.util.regex.Pattern; + import android.app.AlertDialog; import android.app.Dialog; import android.app.ListActivity; @@ -19,9 +22,9 @@ import android.widget.ListView; import android.widget.TextView; import dk.thoerup.android.traininfo.common.DepartureEntry; +import dk.thoerup.android.traininfo.common.StationBean.StationEntry; import dk.thoerup.android.traininfo.common.TimetableBean; import dk.thoerup.android.traininfo.common.TimetableEntry; -import dk.thoerup.android.traininfo.common.StationBean.StationEntry; import dk.thoerup.traininfo.provider.ProviderFactory; import dk.thoerup.traininfo.provider.TimetableProvider; import dk.thoerup.traininfo.util.MessageBox; @@ -37,7 +40,7 @@ TimetableProvider provider; - @SuppressWarnings("unchecked") + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -54,11 +57,30 @@ departure = (DepartureEntry) launchedBy.getSerializableExtra("departure"); ((TextView)findViewById(R.id.Train)).setText(departure.getTrainNumber()); - ((TextView)findViewById(R.id.Status)).setText(departure.getStatus()); - ((TextView)findViewById(R.id.Location)).setText(departure.getLocation()); - ((TextView)findViewById(R.id.Note)).setText(departure.getNote()); + + ((TextView)findViewById(R.id.Location)).setText(departure.getLocation()); ((TextView)findViewById(R.id.Updated)).setText( getLastUpdateString( departure.getUpdated() )); - + + String status = departure.getStatus() != null ? departure.getStatus() : ""; + if ( Pattern.matches("[0-9]+.+min", status) ) { + status += " " + this.getString(R.string.departurebean_delayed); + } + String note = departure.getNote() != null ? departure.getNote() : ""; + note = note.replace("Aflyst", this.getString(R.string.timetablelist_cancelled) ); + note = note.replace("Kører kun til", this.getString(R.string.timetablelist_goesonlyto) ); + note = note.replace("Afgår fra", this.getString(R.string.timetablelist_startsat) ); + note = note.replace("Erstattet af", this.getString(R.string.timetablelist_replacedby) ); + note = note.replace("Eksterne forhold", this.getString(R.string.timetablelist_externalconditions) ); + note = note.replace("Teknisk fejl på et signal", this.getString(R.string.timetablelist_technicalerroronsignal) ); + note = note.replace("Materielforhold", this.getString(R.string.timetablelist_equipmentrelated) ); + note = note.replace("Passagerforhold", this.getString(R.string.timetablelist_passengerrelated) ); + note = note.replace("Forventet rettidig afgang", this.getString(R.string.timetablelist_expectedtimelydeparture) ); + + + + ((TextView)findViewById(R.id.Status)).setText(status); + ((TextView)findViewById(R.id.Note)).setText(note); + ProviderFactory.purgeOldEntries(); //cleanup before fetching more data @@ -164,7 +186,7 @@ super.onPostExecute(result); dismissDialog(DLG_PROGRESS); - + //TODO: differentiate between a communication error and a downed bane.dk site if (timetables != null) { commFailCounter = 0; TimetableList.this.getListView().invalidateViews();