21 |
import android.view.View; |
import android.view.View; |
22 |
import android.widget.ListView; |
import android.widget.ListView; |
23 |
import android.widget.TextView; |
import android.widget.TextView; |
24 |
|
import android.widget.Toast; |
25 |
import dk.thoerup.android.traininfo.common.DepartureEntry; |
import dk.thoerup.android.traininfo.common.DepartureEntry; |
|
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; |
28 |
import dk.thoerup.traininfo.provider.ProviderFactory; |
import dk.thoerup.traininfo.provider.ProviderFactory; |
72 |
note = note.replace("Erstattet af", this.getString(R.string.timetablelist_replacedby) ); |
note = note.replace("Erstattet af", this.getString(R.string.timetablelist_replacedby) ); |
73 |
note = note.replace("Eksterne forhold", this.getString(R.string.timetablelist_externalconditions) ); |
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) ); |
note = note.replace("Teknisk fejl på et signal", this.getString(R.string.timetablelist_technicalerroronsignal) ); |
75 |
note = note.replace("Materielforhold", this.getString(R.string.timetablelist_equipmentcircumstances) ); |
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); |
((TextView)findViewById(R.id.Status)).setText(status); |
82 |
((TextView)findViewById(R.id.Note)).setText(note); |
((TextView)findViewById(R.id.Note)).setText(note); |
105 |
protected void onListItemClick(ListView l, View v, int position, long id) { |
protected void onListItemClick(ListView l, View v, int position, long id) { |
106 |
super.onListItemClick(l, v, position, id); |
super.onListItemClick(l, v, position, id); |
107 |
|
|
108 |
TimetableEntry tt = timetables.entries.get(position); |
if (timetables == null || timetables.entries == null || timetables.entries.size() == 0) { |
109 |
|
Toast.makeText(this, "No timetables in list !?", Toast.LENGTH_LONG).show(); //TODO Translate |
110 |
StationEntry station = new StationEntry(); |
return; |
111 |
station.setName( tt.getStation() ); |
} |
|
station.setId( tt.getStationId() ); |
|
|
station.setIsRegional(true); |
|
112 |
|
|
113 |
|
TimetableEntry tt = timetables.entries.get(position); |
114 |
|
|
115 |
|
|
116 |
Intent intent = new Intent(this, DepartureList.class); |
Intent intent = new Intent(this, DepartureList.class); |
117 |
intent.putExtra("stationbean", station); |
intent.putExtra("stationbean", tt.getStationEntry() ); |
118 |
startActivity(intent); |
startActivity(intent); |
119 |
|
|
120 |
} |
} |
186 |
super.onPostExecute(result); |
super.onPostExecute(result); |
187 |
dismissDialog(DLG_PROGRESS); |
dismissDialog(DLG_PROGRESS); |
188 |
|
|
189 |
|
|
190 |
if (timetables != null) { |
if (timetables != null && timetables.errorCode == null) { |
191 |
commFailCounter = 0; |
commFailCounter = 0; |
192 |
TimetableList.this.getListView().invalidateViews(); |
TimetableList.this.getListView().invalidateViews(); |
193 |
adapter.setTimetable(timetables); |
adapter.setTimetable(timetables); |
197 |
} else { // communication or parse error |
} else { // communication or parse error |
198 |
commFailCounter++; |
commFailCounter++; |
199 |
AlertDialog.Builder builder = new AlertDialog.Builder(TimetableList.this); |
AlertDialog.Builder builder = new AlertDialog.Builder(TimetableList.this); |
200 |
builder.setMessage(getString(timetablelist_fetcherror)); |
|
201 |
|
|
202 |
|
if (timetables != null && timetables.errorCode != null ) { //got an error xml back |
203 |
|
commFailCounter = 10; |
204 |
|
builder.setMessage( getString(R.string.no_backend) ); |
205 |
|
} else { |
206 |
|
builder.setMessage(getString(timetablelist_fetcherror)); |
207 |
|
} |
208 |
|
|
209 |
builder.setCancelable(true); |
builder.setCancelable(true); |
210 |
if (commFailCounter < 3) { |
if (commFailCounter < 3) { |
211 |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |