X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=src%2Fro%2Fieval%2Funical%2FEventListActivity.java;h=18fa49d7b95b6bf5dcdc43bf7495b944498bd6cf;hb=a824030c902a41882e98839fea032f7ccdfc1635;hp=793573b3eec05a220041d0ee046a1f492144903c;hpb=0b5b93a4bba05c21f665c0940d21be70bd7a82ea;p=unical.git diff --git a/src/ro/ieval/unical/EventListActivity.java b/src/ro/ieval/unical/EventListActivity.java index 793573b..18fa49d 100644 --- a/src/ro/ieval/unical/EventListActivity.java +++ b/src/ro/ieval/unical/EventListActivity.java @@ -1,40 +1,82 @@ package ro.ieval.unical; import java.util.Arrays; -import java.util.GregorianCalendar; -import java.text.DateFormat; -import java.util.Date; +import java.util.Comparator; -import ro.ieval.unical.R; import android.app.Activity; +import android.content.Intent; import android.os.Bundle; -import android.text.format.DateUtils; -import android.widget.Button; -import android.widget.LinearLayout; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ListView; public class EventListActivity extends Activity { - GregorianCalendar gc; + long dtstart,dtend; + //Used to refresh events if the user wants to display only certain events + //Sry for bad english + //Muie la comisie + private void displayEvents() { + final Event events[]=Event.getAllEvents(getBaseContext()); + final ListView lv = (ListView) findViewById(R.id.eventlist); + Arrays.sort(events,new EventComparator()); + + final EventAdapter adapter = new EventAdapter(this, events); + lv.setAdapter(adapter); + lv.setOnItemClickListener(new OnItemClickListener() { + + @Override + public void onItemClick(AdapterView arg0, View arg1, int arg2, + long arg3) { + // TODO Auto-generated method stub + DisplayEventActivity.displayEvent(EventListActivity.this,events[arg2]); + } + + }); + } + + private static class EventComparator implements Comparator { + @Override + public int compare(final Event lhs, final Event rhs) { + if(lhs.dtstart < rhs.dtstart) + return -1; + if(lhs.dtstart == rhs.dtstart) + return 0; + return 1; + } + + } + @Override - protected void onCreate(Bundle savedInstanceState) { - // TODO Auto-generated method stub + protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.event_list); - Date d=new Date(); - d.getTime(); - gc=new GregorianCalendar(); - gc.setTime(d); - - Event r[]=Event.getAllEvents(getBaseContext()); - LinearLayout ll = (LinearLayout)findViewById(R.id.eventslayout); - Button[] b=new Button[10]; - Arrays.sort(r,new EventComparator()); - for(int i=0; i