]> iEval git - unical.git/commitdiff
Remove EventRowContainer and add colour to the event list
authorMarius Gavrilescu <marius@ieval.ro>
Sun, 9 Jun 2013 21:26:30 +0000 (00:26 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sun, 9 Jun 2013 21:26:30 +0000 (00:26 +0300)
src/ro/ieval/unical/EventAdapter.java
src/ro/ieval/unical/EventListActivity.java
src/ro/ieval/unical/EventRowContainer.java [deleted file]

index 35245d0cf6e6e1559ac49b09fbe99c7f5b9e671c..73f29fb0d50f93c83b396134970778ae82efe3d2 100644 (file)
@@ -1,4 +1,6 @@
 package ro.ieval.unical;
+import java.util.Date;
+
 import android.content.Context;
 import android.graphics.Color;
 import android.view.LayoutInflater;
@@ -9,10 +11,10 @@ import android.widget.ImageView;
 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;
@@ -27,10 +29,10 @@ public class EventAdapter extends ArrayAdapter<EventRowContainer> {
            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;
         }
index 58fc8b2e221cc94cc9abeabf6bc4396118f3d31e..18fa49d7b95b6bf5dcdc43bf7495b944498bd6cf 100644 (file)
@@ -25,14 +25,8 @@ public class EventListActivity extends Activity {
                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() {
 
diff --git a/src/ro/ieval/unical/EventRowContainer.java b/src/ro/ieval/unical/EventRowContainer.java
deleted file mode 100644 (file)
index 7f08d0d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-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() {
-       }
-}
This page took 0.02772 seconds and 4 git commands to generate.