/[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 1065 by torben, Fri Jun 11 18:46:46 2010 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;  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          @Override
19          public boolean isEnabled(int position) {          public boolean isEnabled(int position) {
20                  return ( timetable.get(position).getStationId() != -1 );                  return ( timetable.entries.get(position).getStationId() != -1 );
21          }          }
22    
23          public TimetableListAdapter(Context context) {          public TimetableListAdapter(Context context) {
# Line 27  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 35  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 52  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                  TimetableBean timetableBean = timetable.get(position);                  TimetableEntry entry = timetable.entries.get(position);
56    
57                  View root = inflater.inflate(R.layout.timetablerow , parent, false);                  View root = inflater.inflate(R.layout.timetablerow , parent, false);
58                                    
59                  TextView station = (TextView) root.findViewById(R.id.Station);                  TextView station = (TextView) root.findViewById(R.id.Station);
60                  station.setText(timetableBean.getStation());                  station.setText(entry.getStation());
61                                    
62                  TextView arrival = (TextView) root.findViewById(R.id.Arrival);                            TextView arrival = (TextView) root.findViewById(R.id.Arrival);          
63                  arrival.setText(timetableBean.getArrival());                  arrival.setText(entry.getArrival());
64                                    
65                  TextView departure = (TextView) root.findViewById(R.id.Departure);                                TextView departure = (TextView) root.findViewById(R.id.Departure);              
66                  departure.setText(timetableBean.getDeparture());                  departure.setText(entry.getDeparture());
67                                    
68                                    
69                  if (timetableBean.isCurrent()) {                  if (entry.isCurrent()) {
70                          final int bgcolor = 0xFFFFFFFF;                          final int bgcolor = 0xFFFFFFFF;
71                          final int fgcolor = 0xFF000000;                          final int fgcolor = 0xFF000000;
72                                                    

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

  ViewVC Help
Powered by ViewVC 1.1.20