package ro.ieval.unical;
+import java.util.Date;
+
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.widget.TextView;
-public class EventAdapter extends ArrayAdapter<EventRowContainer> {
- private final EventRowContainer[] values;
+public class EventAdapter extends ArrayAdapter<Event> {
+ private final Event[] values;
private final Context context;
- public EventAdapter(Context context,EventRowContainer[] values) {
+ public EventAdapter(Context context,Event[] values) {
super(context,R.layout.event_row_layout,values);
this.context=context;
this.values=values;
TextView dstart = (TextView) rowView.findViewById(R.id.smalldatestart);
TextView dend = (TextView) rowView.findViewById(R.id.smalldateend);
ImageView header = (ImageView) rowView.findViewById(R.id.rowHeader);
- header.setBackgroundColor(Color.CYAN);
- title.setText(values[position].name);
- dstart.setText(values[position].dtstart.toString());
- dend.setText(values[position].dtend.toString());
+ header.setBackgroundColor(values[position].eventColour);
+ title.setText(values[position].title);
+ dstart.setText(new Date(values[position].dtstart).toString());
+ dend.setText(new Date(values[position].dtend).toString());
return rowView;
}
final Event events[]=Event.getAllEvents(getBaseContext());
final ListView lv = (ListView) findViewById(R.id.eventlist);
Arrays.sort(events,new EventComparator());
-
- EventRowContainer r[]=new EventRowContainer[events.length];
- for(int i=0; i<events.length; ++i) {
- EventRowContainer c=new EventRowContainer(i,events[i].title, events[i].dtstart, events[i].dtend);
- r[i]=c;
- //System.out.println(events[i].eventColour);
- }
- final EventAdapter adapter = new EventAdapter(this, r);
+
+ final EventAdapter adapter = new EventAdapter(this, events);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new OnItemClickListener() {
+++ /dev/null
-package ro.ieval.unical;
-
-import java.util.Date;
-
-public class EventRowContainer {
- public String name;
- public Date dtstart,dtend;
- public int id;
- public EventRowContainer(int id,String n,long ds,long de) {
- // Container used to hold information for adapter
- this.id=id;
- this.name=n;
- this.dtstart=new Date(ds);
- this.dtend=new Date(de);
- }
- public EventRowContainer() {
- }
-}