/[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 1066 by torben, Thu Sep 16 15:32:42 2010 UTC revision 1454 by torben, Thu May 5 15:32:04 2011 UTC
# Line 15  import dk.thoerup.android.traininfo.comm Line 15  import dk.thoerup.android.traininfo.comm
15    
16  public class DepartureListAdapter extends BaseAdapter {  public class DepartureListAdapter extends BaseAdapter {
17    
18            boolean showDetails = false;
19          private List<DepartureEntry> departures;          private List<DepartureEntry> departures;
20          LayoutInflater inflater;          LayoutInflater inflater;
21          Context context;          Context context;
# Line 28  public class DepartureListAdapter extend Line 29  public class DepartureListAdapter extend
29                  super();                  super();
30                  this.context = context;                  this.context = context;
31                                    
32                  inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);                  inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);          
33            }
34                                    
35    
36            public void toggleShowDetails() {
37                    showDetails = !showDetails;
38                    notifyDataSetChanged();
39          }          }
40                    
41          public void setDepartures(List<DepartureEntry> departures) {          public void setDepartures(List<DepartureEntry> departures) {
# Line 90  public class DepartureListAdapter extend Line 96  public class DepartureListAdapter extend
96                                    
97                  ImageView typeIcon = (ImageView) root.findViewById(R.id.TypeIcon);                  ImageView typeIcon = (ImageView) root.findViewById(R.id.TypeIcon);
98                  String trainNumber = station.getTrainNumber().trim();                  String trainNumber = station.getTrainNumber().trim();
99                  String code = trainNumber.split(" ")[0].toLowerCase();                  String trainParts[] = trainNumber.split(" ");
100                    String code = trainParts[0].toLowerCase();
101                    
102                    if (showDetails) {
103                            root.findViewById(R.id.departureRow2).setVisibility( View.VISIBLE );                    
104                            ((TextView) root.findViewById(R.id.TrainNumber)).setText(trainNumber);
105                            ((TextView) root.findViewById(R.id.Origin)).setText( station.getOrigin() );
106                    }
107                    
108                  Integer imageId = imageMap.get(code);                  Integer imageId = imageMap.get(code);
109                  if (imageId != null) {                  if (imageId != null) {
110                          typeIcon.setImageResource(imageId);                          typeIcon.setImageResource(imageId);
# Line 102  public class DepartureListAdapter extend Line 115  public class DepartureListAdapter extend
115                  return root;                  return root;
116          }          }
117                    
118            //TODO: all these traintypes / icons should be explained somewhere
119          private static void buildImageMap() {          private static void buildImageMap() {
120                  imageMap.put("ra", R.drawable.re); //RA = regionaltog arriva                  imageMap.put("ec", R.drawable.ec); //EC = EuroCity
121                  imageMap.put("re", R.drawable.re); //RE = Regionaltog                  // Missing FP ?
                 imageMap.put("l", R.drawable.lyn); //L =  Lyn  
122                  imageMap.put("ic", R.drawable.ic); //IC = Intercity                  imageMap.put("ic", R.drawable.ic); //IC = Intercity
123                    imageMap.put("il", R.drawable.il); //IntercityLyn Nonstop
124                    // Missing Int ?
125                    // Missing IR ?
126                    imageMap.put("l", R.drawable.lyn); //L =  Lyn
127                  imageMap.put("pp", R.drawable.pp); //PP = Privatbaner (eg. odderbanen eller LokalBanen)                  imageMap.put("pp", R.drawable.pp); //PP = Privatbaner (eg. odderbanen eller LokalBanen)
128                    // Missing PX
129                    imageMap.put("ra", R.drawable.re); //RA = regionaltog arriva
130                    imageMap.put("re", R.drawable.re); //RE = Regionaltog          
131                  imageMap.put("ør", R.drawable.or); //ØR = Øresundstog                  imageMap.put("ør", R.drawable.or); //ØR = Øresundstog
132                  imageMap.put("ec", R.drawable.ec); //EC = EuroCity                                                          
133                  imageMap.put("sj", R.drawable.sj); // SJ=Svenska Jernbaner                  imageMap.put("sj", R.drawable.sj); //SJ=Svenska Jernbaner -- not mentioned on bane.dk
134                  imageMap.put("ie", R.drawable.ie);                  imageMap.put("ie", R.drawable.ie); //what's this ?? -- not mentioned on bane.dk
135                    
136                    //Missing IB ? -- not mentioned on bane.dk
137                    //Missing RX ? -- not mentioned on bane.dk
138                    
139                                    
140                  imageMap.put("a", R.drawable.stog_a);   //S-Tog: A banen #00b5f1                                                  imageMap.put("a", R.drawable.stog_a);   //S-Tog: A banen #00b5f1                                
141                  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.1066  
changed lines
  Added in v.1454

  ViewVC Help
Powered by ViewVC 1.1.20