From 0b5b93a4bba05c21f665c0940d21be70bd7a82ea Mon Sep 17 00:00:00 2001 From: Petru Trimbitas Date: Sun, 9 Jun 2013 13:11:14 +0300 Subject: [PATCH] Add Activity to display a list of events --- AndroidManifest.xml | 1 + gson/com/google/gson/JsonNull.java | 0 gson/com/google/gson/JsonParser.java | 0 res/layout/event_list.xml | 22 ++++++++++ res/menu/event.xml | 6 +++ res/values/strings.xml | 2 + src/ro/ieval/unical/DisplayEventActivity.java | 9 ++++- src/ro/ieval/unical/Event.java | 1 + src/ro/ieval/unical/EventListActivity.java | 40 +++++++++++++++++++ 9 files changed, 80 insertions(+), 1 deletion(-) mode change 100755 => 100644 gson/com/google/gson/JsonNull.java mode change 100755 => 100644 gson/com/google/gson/JsonParser.java create mode 100644 res/layout/event_list.xml create mode 100644 src/ro/ieval/unical/EventListActivity.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index f2d66b4..2ba8ef0 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -25,6 +25,7 @@ + \ No newline at end of file diff --git a/gson/com/google/gson/JsonNull.java b/gson/com/google/gson/JsonNull.java old mode 100755 new mode 100644 diff --git a/gson/com/google/gson/JsonParser.java b/gson/com/google/gson/JsonParser.java old mode 100755 new mode 100644 diff --git a/res/layout/event_list.xml b/res/layout/event_list.xml new file mode 100644 index 0000000..cc212a8 --- /dev/null +++ b/res/layout/event_list.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/res/menu/event.xml b/res/menu/event.xml index 9a454e1..f4ce275 100644 --- a/res/menu/event.xml +++ b/res/menu/event.xml @@ -7,6 +7,12 @@ android:titleCondensed="NEW"> + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 482b58a..f3b0ab1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11,6 +11,8 @@ Password Location: Repeating + Today + Event List Yes No Delete this event ? diff --git a/src/ro/ieval/unical/DisplayEventActivity.java b/src/ro/ieval/unical/DisplayEventActivity.java index 6208d23..af68224 100644 --- a/src/ro/ieval/unical/DisplayEventActivity.java +++ b/src/ro/ieval/unical/DisplayEventActivity.java @@ -1,5 +1,6 @@ package ro.ieval.unical; +import java.util.Arrays; import java.util.Date; import android.app.Activity; @@ -25,10 +26,12 @@ public class DisplayEventActivity extends Activity { super.onCreate(savedInstanceState); final Event e=getIntent().getParcelableExtra(EXTRA_EVENT); setContentView(R.layout.event_view); + final TextView eventTitle= (TextView) findViewById(R.id.eventTitle); final TextView date=(TextView) findViewById(R.id.date); final TextView description=(TextView) findViewById(R.id.description); final TextView location= (TextView) findViewById(R.id.location); + eventTitle.setText(e.title); date.setText(new Date(e.dtstart).toString()); description.setText(e.description); @@ -45,7 +48,7 @@ public class DisplayEventActivity extends Activity { @Override public boolean onOptionsItemSelected(final MenuItem item) { // Handle item selection - switch (item.getItemId()) { + switch (item. getItemId()) { case R.id.NewEvent: final Intent i=new Intent(this,AddEventActivity.class); startActivity(i); @@ -54,6 +57,10 @@ public class DisplayEventActivity extends Activity { final DeleteEventDialog d=new DeleteEventDialog(); d.show(getFragmentManager(), "Delete"); return true; + case R.id.eventlist: + final Intent it=new Intent(this,EventListActivity.class); + startActivity(it); + return true; default: return true; } diff --git a/src/ro/ieval/unical/Event.java b/src/ro/ieval/unical/Event.java index 23ccd74..cdeafaf 100644 --- a/src/ro/ieval/unical/Event.java +++ b/src/ro/ieval/unical/Event.java @@ -1,6 +1,7 @@ package ro.ieval.unical; import java.util.ArrayList; +import java.util.Arrays; import android.content.ContentResolver; import android.content.Context; diff --git a/src/ro/ieval/unical/EventListActivity.java b/src/ro/ieval/unical/EventListActivity.java new file mode 100644 index 0000000..793573b --- /dev/null +++ b/src/ro/ieval/unical/EventListActivity.java @@ -0,0 +1,40 @@ +package ro.ieval.unical; + +import java.util.Arrays; +import java.util.GregorianCalendar; +import java.text.DateFormat; +import java.util.Date; + +import ro.ieval.unical.R; +import android.app.Activity; +import android.os.Bundle; +import android.text.format.DateUtils; +import android.widget.Button; +import android.widget.LinearLayout; + + +public class EventListActivity extends Activity { + GregorianCalendar gc; + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + 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