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

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

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

revision 491 by torben, Thu Oct 29 19:50:02 2009 UTC revision 981 by torben, Sat Jul 10 16:03:10 2010 UTC
# Line 14  import android.widget.TextView; Line 14  import android.widget.TextView;
14    
15  public class DepartureListAdapter extends BaseAdapter {  public class DepartureListAdapter extends BaseAdapter {
16    
17          private List<DepartureBean> departures;          private List<DepartureEntry> departures;
18          LayoutInflater inflater;          LayoutInflater inflater;
19          Context context;          Context context;
20                    
# Line 31  public class DepartureListAdapter extend Line 31  public class DepartureListAdapter extend
31                                    
32          }          }
33                    
34          public void setDepartures(List<DepartureBean> departures) {          public void setDepartures(List<DepartureEntry> departures) {
35                  this.departures = departures;                  this.departures = departures;
36                  notifyDataSetChanged();                  notifyDataSetChanged();
37          }          }
# Line 44  public class DepartureListAdapter extend Line 44  public class DepartureListAdapter extend
44                          return 0;                          return 0;
45          }          }
46                    
47          public DepartureBean getDeparture(int position) {          public DepartureEntry getDeparture(int position) {
48                  return departures.get(position);                  return departures.get(position);
49          }          }
50    
# Line 60  public class DepartureListAdapter extend Line 60  public class DepartureListAdapter extend
60    
61          @Override          @Override
62          public View getView(int position, View convertView, ViewGroup parent) {          public View getView(int position, View convertView, ViewGroup parent) {
63                  DepartureBean station = departures.get(position);                  DepartureEntry station = departures.get(position);
64    
65                  View root = inflater.inflate(R.layout.departurerow , parent, false);                  View root = inflater.inflate(R.layout.departurerow , parent, false);
66                                    
# Line 70  public class DepartureListAdapter extend Line 70  public class DepartureListAdapter extend
70                  if (station.getStatus().length() > 0 || station.getNote().length() > 0) {                  if (station.getStatus().length() > 0 || station.getNote().length() > 0) {
71                          ImageView image = (ImageView) root.findViewById(R.id.InfoIcon);                          ImageView image = (ImageView) root.findViewById(R.id.InfoIcon);
72                                                    
73                            String status = station.getStatus().toLowerCase();
74                            String note = station.getNote().toLowerCase();
75                            
76                          int iconID;                          int iconID;
77                          if (station.getStatus().toLowerCase().indexOf("aflyst") > -1 ||                          if (status.indexOf("aflyst") > -1 || note.indexOf("aflyst") > -1 ) {
                                         station.getNote().toLowerCase().indexOf("aflyst") > -1 ) {  
78                                  iconID = R.drawable.warn20;                                  iconID = R.drawable.warn20;
79                            } else if (note.indexOf("kører kun til") > -1 || note.indexOf("afgår fra") > -1) { //If these strings are present, the train only covers part of the line
80                                    iconID = R.drawable.warnyellow20;
81                          } else {                          } else {
82                                  iconID = R.drawable.info20;                                  iconID = R.drawable.info20;
83                          }                          }
# Line 104  public class DepartureListAdapter extend Line 108  public class DepartureListAdapter extend
108                  imageMap.put("ør", R.drawable.or); //ØR = Øresundstog                  imageMap.put("ør", R.drawable.or); //ØR = Øresundstog
109                  imageMap.put("ec", R.drawable.ec); //EC = EuroCity                  imageMap.put("ec", R.drawable.ec); //EC = EuroCity
110                  imageMap.put("sj", R.drawable.sj); // SJ=Svenska Jernbaner                  imageMap.put("sj", R.drawable.sj); // SJ=Svenska Jernbaner
111                    imageMap.put("ie", R.drawable.ie);
112                                    
113                  imageMap.put("a", R.drawable.stog_a);   //S-Tog: A banen #00b5f1                                                  imageMap.put("a", R.drawable.stog_a);   //S-Tog: A banen #00b5f1                                
114                  imageMap.put("b", R.drawable.stog_b);   //S-Tog:B banen #5aba52                  imageMap.put("b", R.drawable.stog_b);   //S-Tog:B banen #5aba52

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

  ViewVC Help
Powered by ViewVC 1.1.20