/[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 1433 by torben, Thu Sep 16 15:32:42 2010 UTC revision 1434 by torben, Tue May 3 16:28:56 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            public void setShowDetails(boolean showDetails) {
36                    this.showDetails = showDetails;
37            }
38            
39            public boolean getShowDetails() {
40                    return showDetails;
41            }
42            
43            public void toggleShowDetails() {
44                    showDetails = !showDetails;
45                    notifyDataSetChanged();
46          }          }
47                    
48          public void setDepartures(List<DepartureEntry> departures) {          public void setDepartures(List<DepartureEntry> departures) {
# Line 90  public class DepartureListAdapter extend Line 103  public class DepartureListAdapter extend
103                                    
104                  ImageView typeIcon = (ImageView) root.findViewById(R.id.TypeIcon);                  ImageView typeIcon = (ImageView) root.findViewById(R.id.TypeIcon);
105                  String trainNumber = station.getTrainNumber().trim();                  String trainNumber = station.getTrainNumber().trim();
106                  String code = trainNumber.split(" ")[0].toLowerCase();                  String trainParts[] = trainNumber.split(" ");
107                    String code = trainParts[0].toLowerCase();
108                    
109                    if (showDetails) {
110                            root.findViewById(R.id.departureRow2).setVisibility( View.VISIBLE );                    
111                            ((TextView) root.findViewById(R.id.TrainNumber)).setText(trainNumber);
112                            ((TextView) root.findViewById(R.id.Origin)).setText( station.getOrigin() );
113                    }
114                    
115                  Integer imageId = imageMap.get(code);                  Integer imageId = imageMap.get(code);
116                  if (imageId != null) {                  if (imageId != null) {
117                          typeIcon.setImageResource(imageId);                          typeIcon.setImageResource(imageId);
# Line 102  public class DepartureListAdapter extend Line 122  public class DepartureListAdapter extend
122                  return root;                  return root;
123          }          }
124                    
125            //TODO: all these traintypes / icons should be explained somewhere
126          private static void buildImageMap() {          private static void buildImageMap() {
127                  imageMap.put("ra", R.drawable.re); //RA = regionaltog arriva                  imageMap.put("ra", R.drawable.re); //RA = regionaltog arriva
128                  imageMap.put("re", R.drawable.re); //RE = Regionaltog                  imageMap.put("re", R.drawable.re); //RE = Regionaltog
# Line 112  public class DepartureListAdapter extend Line 133  public class DepartureListAdapter extend
133                  imageMap.put("ec", R.drawable.ec); //EC = EuroCity                  imageMap.put("ec", R.drawable.ec); //EC = EuroCity
134                  imageMap.put("sj", R.drawable.sj); // SJ=Svenska Jernbaner                  imageMap.put("sj", R.drawable.sj); // SJ=Svenska Jernbaner
135                  imageMap.put("ie", R.drawable.ie);                  imageMap.put("ie", R.drawable.ie);
136                    //TODO: missing IL: IntercityLyn Nonstop
137                                    
138                  imageMap.put("a", R.drawable.stog_a);   //S-Tog: A banen #00b5f1                                                  imageMap.put("a", R.drawable.stog_a);   //S-Tog: A banen #00b5f1                                
139                  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.1433  
changed lines
  Added in v.1434

  ViewVC Help
Powered by ViewVC 1.1.20