From ad349897bb277240bdc5610b9a62d78e5327157b Mon Sep 17 00:00:00 2001 From: Petru Date: Tue, 13 Aug 2013 11:38:27 +0300 Subject: [PATCH] Edit event. work in progress --- res/menu/event.xml | 15 ++++++++++++++- res/values/strings.xml | 1 + src/ro/ieval/unical/AddEventActivity.java | 10 ++++++++++ src/ro/ieval/unical/DisplayEventActivity.java | 5 ++++- src/ro/ieval/unical/Event.java | 6 ++++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/res/menu/event.xml b/res/menu/event.xml index 1dde058..6a85413 100644 --- a/res/menu/event.xml +++ b/res/menu/event.xml @@ -1,11 +1,24 @@ - + + + + + + years Refresh Stop Alarm + Edit Event Day diff --git a/src/ro/ieval/unical/AddEventActivity.java b/src/ro/ieval/unical/AddEventActivity.java index c3d3620..89fe73e 100644 --- a/src/ro/ieval/unical/AddEventActivity.java +++ b/src/ro/ieval/unical/AddEventActivity.java @@ -7,6 +7,8 @@ import android.app.Activity; import android.app.DatePickerDialog.OnDateSetListener; import android.app.Fragment; import android.app.TimePickerDialog.OnTimeSetListener; +import android.content.Context; +import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; @@ -17,6 +19,14 @@ import android.widget.*; public final class AddEventActivity extends Activity implements OnDateSetListener, OnTimeSetListener{ private TextView dateTimeTextView; private Event tempEvent=new Event(); + public static final String EXTRA_EVENT = "event"; + + public static void editEvent(final Context c, final Event e) { + Intent i = new Intent(c,AddEventActivity.class); + i.putExtra(AddEventActivity.EXTRA_EVENT,e); + c.startActivity(i); + } + @Override protected void onCreate(final Bundle savedInstanceState) { diff --git a/src/ro/ieval/unical/DisplayEventActivity.java b/src/ro/ieval/unical/DisplayEventActivity.java index bb819b9..275b2dc 100644 --- a/src/ro/ieval/unical/DisplayEventActivity.java +++ b/src/ro/ieval/unical/DisplayEventActivity.java @@ -45,7 +45,7 @@ public class DisplayEventActivity extends Activity { final SimpleDateFormat dayOfWeekFormat = new SimpleDateFormat("EEEEEEE", Locale.UK); startDay.setText(dayOfWeekFormat.format(start)); - if(dateFormat.format(start)!=dateFormat.format(end)) { + if(!dateFormat.format(start).equals(dateFormat.format(end))) { endDay.setText(dayOfWeekFormat.format(end)); endDate.setText(dateFormat.format(end)); } @@ -78,6 +78,9 @@ public class DisplayEventActivity extends Activity { final Intent it=new Intent(this,EventListActivity.class); startActivity(it); return true; + case R.id.edit_event: + AddEventActivity.editEvent(DisplayEventActivity.this,event); + return true; default: return true; } diff --git a/src/ro/ieval/unical/Event.java b/src/ro/ieval/unical/Event.java index 8839838..9e4fef8 100644 --- a/src/ro/ieval/unical/Event.java +++ b/src/ro/ieval/unical/Event.java @@ -96,6 +96,12 @@ final class Event implements Parcelable{ return r.toArray(new Event[r.size()]); } + public void insert(final Context context) { + final ContentResolver cr=context.getContentResolver(); + //cr.insert(Uri.withAppendedPath(Events.CONTENT_URI)); + //cr.notifyChange(); + } + public void delete(final Context context){ final ContentResolver cr=context.getContentResolver(); cr.delete(Uri.withAppendedPath(Events.CONTENT_URI, Long.toString(_id)), null, null); -- 2.39.2