17 |
import dk.thoerup.traininfo.provider.ProviderFactory; |
import dk.thoerup.traininfo.provider.ProviderFactory; |
18 |
import dk.thoerup.traininfo.provider.TimetableProvider; |
import dk.thoerup.traininfo.provider.TimetableProvider; |
19 |
import dk.thoerup.traininfo.util.MessageBox; |
import dk.thoerup.traininfo.util.MessageBox; |
20 |
|
import static dk.thoerup.traininfo.R.string.*; |
21 |
|
|
22 |
public class TimetableList extends Activity { |
public class TimetableList extends Activity { |
23 |
|
|
48 |
|
|
49 |
((TextView)findViewById(R.id.Train)).setText(departure.getTrainNumber()); |
((TextView)findViewById(R.id.Train)).setText(departure.getTrainNumber()); |
50 |
((TextView)findViewById(R.id.Status)).setText(departure.getStatus()); |
((TextView)findViewById(R.id.Status)).setText(departure.getStatus()); |
51 |
|
((TextView)findViewById(R.id.Location)).setText(departure.getLocation()); |
52 |
((TextView)findViewById(R.id.Note)).setText(departure.getNote()); |
((TextView)findViewById(R.id.Note)).setText(departure.getNote()); |
53 |
((TextView)findViewById(R.id.Updated)).setText(departure.getLastUpdateString()); |
((TextView)findViewById(R.id.Updated)).setText(departure.getLastUpdateString()); |
54 |
|
|
98 |
protected Dialog onCreateDialog(int id) { |
protected Dialog onCreateDialog(int id) { |
99 |
switch (id) { |
switch (id) { |
100 |
case DLG_PROGRESS: |
case DLG_PROGRESS: |
101 |
ProgressDialog dlg = new ProgressDialog(this); |
ProgressDialog dlg = new ProgressDialog(this); |
102 |
dlg.setMessage("Fetch timetable data"); |
dlg.setMessage( getString(timetablelist_fetchdata) ); |
103 |
dlg.setCancelable(true); |
dlg.setCancelable(true); |
104 |
return dlg; |
return dlg; |
105 |
default: |
default: |
126 |
if (success) { |
if (success) { |
127 |
adapter.setTimetable(timetables); |
adapter.setTimetable(timetables); |
128 |
if (timetables.size() == 0) { |
if (timetables.size() == 0) { |
129 |
MessageBox.showMessage(TimetableList.this, "No timetable found"); |
MessageBox.showMessage(TimetableList.this, getString(timetablelist_nodata)); |
130 |
} |
} |
131 |
} else { // communication or parse error |
} else { // communication or parse error |
132 |
AlertDialog.Builder builder = new AlertDialog.Builder(TimetableList.this); |
AlertDialog.Builder builder = new AlertDialog.Builder(TimetableList.this); |
133 |
builder.setMessage("Error finding departures"); |
builder.setMessage(getString(timetablelist_fetcherror)); |
134 |
builder.setCancelable(true); |
builder.setCancelable(true); |
135 |
builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() { |
builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() { |
136 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
137 |
dialog.dismiss(); |
dialog.dismiss(); |
138 |
startTimetableFetcher(); |
startTimetableFetcher(); |
139 |
|
|
140 |
} |
} |
141 |
}); |
}); |
142 |
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { |
builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() { |
143 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
144 |
dialog.dismiss(); |
dialog.dismiss(); |
145 |
} |
} |