/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/DepartureList.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 835 by torben, Fri Jun 11 14:05:24 2010 UTC revision 981 by torben, Sat Jul 10 16:03:10 2010 UTC
# Line 7  import static dk.thoerup.traininfo.R.str Line 7  import static dk.thoerup.traininfo.R.str
7    
8    
9  import java.text.NumberFormat;  import java.text.NumberFormat;
10  import java.util.ArrayList;  
 import java.util.List;  
11    
12  import android.app.AlertDialog;  import android.app.AlertDialog;
13  import android.app.Dialog;  import android.app.Dialog;
# Line 36  public class DepartureList extends ListA Line 35  public class DepartureList extends ListA
35                    
36          DepartureListAdapter adapter;          DepartureListAdapter adapter;
37          DepartureProvider provider;          DepartureProvider provider;
38          List<DepartureBean> departures;          DepartureBean departures;
39                    
40          int selectedItemId;          int selectedItemId;
41          //DepartureBean currentDeparture;          //DepartureBean currentDeparture;
# Line 49  public class DepartureList extends ListA Line 48  public class DepartureList extends ListA
48                    
49          boolean arrival = false;          boolean arrival = false;
50                    
51          @SuppressWarnings("unchecked")  
52          @Override          @Override
53          protected void onCreate(Bundle savedInstanceState) {          protected void onCreate(Bundle savedInstanceState) {
54                  super.onCreate(savedInstanceState);                  super.onCreate(savedInstanceState);
# Line 118  public class DepartureList extends ListA Line 117  public class DepartureList extends ListA
117                          if (savedInstanceState == null) {                          if (savedInstanceState == null) {
118                                  startDepartureFetcher();                                  startDepartureFetcher();
119                          } else {                          } else {
120                                  departures = (List<DepartureBean>) savedInstanceState.getSerializable("departures");                                  departures = (DepartureBean) savedInstanceState.getSerializable("departures");
121                                  adapter.setDepartures(departures);                                  adapter.setDepartures(departures.entries);
122                                  selectedItemId = savedInstanceState.getInt("selectedItemId");                                    selectedItemId = savedInstanceState.getInt("selectedItemId");  
123                          }                          }
124                  }                  }
# Line 133  public class DepartureList extends ListA Line 132  public class DepartureList extends ListA
132    
133          outState.putInt("selectedItemId", selectedItemId);          outState.putInt("selectedItemId", selectedItemId);
134                    
135          outState.putSerializable("departures", (ArrayList<DepartureBean>) departures);          outState.putSerializable("departures",  departures);
136      }      }
137        
138        
139                    
140          @Override          @Override
141            protected void onDestroy() {
142                    super.onDestroy();
143                    
144                    if (fetcher != null) {
145                            fetcher.cancel(true);
146                    }
147            }
148    
149            @Override
150          protected void onListItemClick(ListView l, View v, int position, long id) {          protected void onListItemClick(ListView l, View v, int position, long id) {
151                  super.onListItemClick(l, v, position, id);                  super.onListItemClick(l, v, position, id);
152                                    
153                  selectedItemId = position;                  selectedItemId = position;
154                                    
155                  DepartureBean dep = departures.get(selectedItemId);                  DepartureEntry dep = departures.entries.get(selectedItemId);
156                    
157                  Intent intent = new Intent(this, TimetableList.class);                  Intent intent = new Intent(this, TimetableList.class);
158                  intent.putExtra("departure", dep);                  intent.putExtra("departure", dep);
# Line 220  public class DepartureList extends ListA Line 230  public class DepartureList extends ListA
230                          pgDialog.dismiss();                          pgDialog.dismiss();
231                                                    
232                          if (success) {                          if (success) {
233                                  adapter.setDepartures(departures);                                  DepartureList.this.getListView().setVisibility(View.GONE); //Experimental, inspired by http://osdir.com/ml/Android-Developers/2010-04/msg01198.html
234                                  if (departures.size() == 0) {                                  adapter.setDepartures(departures.entries);
235                                          MessageBox.showMessage(DepartureList.this, "No departures found");                                  DepartureList.this.getListView().setVisibility(View.VISIBLE);
236                                    
237                                    if (departures.entries.size() == 0) {
238                                            MessageBox.showMessage(DepartureList.this, "No departures found", true);
239                                  }                                  }
240                          } else { // communication or parse error                          } else { // communication or parse error
241                                  AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this);                                                                                AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this);                                              
# Line 238  public class DepartureList extends ListA Line 251  public class DepartureList extends ListA
251                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
252                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
253                                                  dialog.dismiss();                                                  dialog.dismiss();
254                                                    DepartureList.this.finish();
255                                          }                                                                                                }                                                      
256                                  });                                  });
257                                                                    

Legend:
Removed from v.835  
changed lines
  Added in v.981

  ViewVC Help
Powered by ViewVC 1.1.20