]> iEval git - unical.git/commitdiff
ListView now displays the first event that isn't finished
authorPetru Trimbitas <l3asketballplayer@yahoo.com>
Mon, 10 Jun 2013 10:41:00 +0000 (13:41 +0300)
committerPetru Trimbitas <l3asketballplayer@yahoo.com>
Mon, 10 Jun 2013 10:41:00 +0000 (13:41 +0300)
src/ro/ieval/unical/EventListActivity.java

index 7379d59c6a1dcdcb897906a92237dddb6d8e1641..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,10 +25,16 @@ 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());
+               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
This page took 0.026015 seconds and 4 git commands to generate.