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

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

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

revision 362 by torben, Tue Sep 29 21:30:16 2009 UTC revision 1066 by torben, Thu Sep 16 15:32:42 2010 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfo;  package dk.thoerup.traininfo;
2    
 import java.util.List;  
   
3  import android.content.Context;  import android.content.Context;
4  import android.view.LayoutInflater;  import android.view.LayoutInflater;
5  import android.view.View;  import android.view.View;
6  import android.view.ViewGroup;  import android.view.ViewGroup;
7  import android.widget.BaseAdapter;  import android.widget.BaseAdapter;
8    import android.widget.TextView;
9    import dk.thoerup.android.traininfo.common.TimetableBean;
10    import dk.thoerup.android.traininfo.common.TimetableEntry;
11    
12  public class TimetableListAdapter extends BaseAdapter {  public class TimetableListAdapter extends BaseAdapter {
13    
14          private List<TimetableBean> timetable;          private TimetableBean timetable;
15          LayoutInflater inflater;          LayoutInflater inflater;
16          Context context;          Context context;
17                    
18            @Override
19            public boolean isEnabled(int position) {
20                    return ( timetable.entries.get(position).getStationId() != -1 );
21            }
22    
23          public TimetableListAdapter(Context context) {          public TimetableListAdapter(Context context) {
24                  super();                  super();
25                  this.context = context;                  this.context = context;
# Line 21  public class TimetableListAdapter extend Line 27  public class TimetableListAdapter extend
27                  inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);                  inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
28          }          }
29                    
30          public void setTimetable(List<TimetableBean> timetable) {          public void setTimetable(TimetableBean timetable) {
31                  this.timetable = timetable;                  this.timetable = timetable;
32                  notifyDataSetChanged();                  notifyDataSetChanged();
33          }          }
# Line 29  public class TimetableListAdapter extend Line 35  public class TimetableListAdapter extend
35          @Override          @Override
36          public int getCount() {          public int getCount() {
37                  if (timetable != null)                  if (timetable != null)
38                          return timetable.size();                          return timetable.entries.size();
39                  else                  else
40                          return 0;                          return 0;
41          }          }
# Line 46  public class TimetableListAdapter extend Line 52  public class TimetableListAdapter extend
52    
53          @Override          @Override
54          public View getView(int position, View convertView, ViewGroup parent) {          public View getView(int position, View convertView, ViewGroup parent) {
55                  // TODO Auto-generated method stub                  TimetableEntry entry = timetable.entries.get(position);
56                  return null;  
57                    View root = inflater.inflate(R.layout.timetablerow , parent, false);
58                    
59                    TextView station = (TextView) root.findViewById(R.id.Station);
60                    station.setText(entry.getStation());
61                    
62                    TextView arrival = (TextView) root.findViewById(R.id.Arrival);          
63                    arrival.setText(entry.getArrival());
64                    
65                    TextView departure = (TextView) root.findViewById(R.id.Departure);              
66                    departure.setText(entry.getDeparture());
67                    
68                    
69                    if (entry.isCurrent()) {
70                            final int bgcolor = 0xFFFFFFFF;
71                            final int fgcolor = 0xFF000000;
72                            
73                            station.setTextColor(fgcolor);
74                            arrival.setTextColor(fgcolor);
75                            departure.setTextColor(fgcolor);
76                            root.setBackgroundColor(bgcolor);
77                    }
78                    
79                    return root;
80          }          }
81    
82  }  }

Legend:
Removed from v.362  
changed lines
  Added in v.1066

  ViewVC Help
Powered by ViewVC 1.1.20