]> iEval git - unical.git/blobdiff - src/ro/ieval/unical/EventListActivity.java
ListView now displays the first event that isn't finished
[unical.git] / src / ro / ieval / unical / EventListActivity.java
index 58fc8b2e221cc94cc9abeabf6bc4396118f3d31e..cb2ee6d71ca69c46c892226ae833ad15889c2af1 100644 (file)
@@ -2,6 +2,7 @@ package ro.ieval.unical;
 
 import java.util.Arrays;
 import java.util.Comparator;
+import java.util.Date;
 
 import android.app.Activity;
 import android.content.Intent;
@@ -24,22 +25,21 @@ public class EventListActivity extends Activity {
        private void displayEvents() {
                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);
+               int idx=-1;//index of the first event to be displayed
+               for(int i=0; i<events.length; ++i) 
+                       if(idx==-1 && events[i].dtend>new Date().getTime()) idx=i;
+               if(idx==-1) idx=0;
+
+               final EventAdapter adapter = new EventAdapter(this, events);
                lv.setAdapter(adapter);
+               lv.setSelectionFromTop(idx, 0);
                lv.setOnItemClickListener(new OnItemClickListener() {
 
                        @Override
-                       public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
-                                       long arg3) {
-                               // TODO Auto-generated method stub
+                       public void onItemClick(final AdapterView<?> arg0, final View arg1, final int arg2,
+                                       final long arg3) {
                                DisplayEventActivity.displayEvent(EventListActivity.this,events[arg2]);
                        }
                        
This page took 0.022286 seconds and 4 git commands to generate.