From bbab7d107a15806894f0450c0dc10e195aed5b30 Mon Sep 17 00:00:00 2001 From: Petru Trimbitas Date: Mon, 10 Jun 2013 13:41:00 +0300 Subject: [PATCH] ListView now displays the first event that isn't finished --- src/ro/ieval/unical/EventListActivity.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ro/ieval/unical/EventListActivity.java b/src/ro/ieval/unical/EventListActivity.java index 7379d59..cb2ee6d 100644 --- a/src/ro/ieval/unical/EventListActivity.java +++ b/src/ro/ieval/unical/EventListActivity.java @@ -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; inew 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 -- 2.39.2