From c32befcc9dc90ca41784cd234ae3b9ba695cb640 Mon Sep 17 00:00:00 2001 From: Petru Date: Mon, 15 Jul 2013 19:13:55 +0300 Subject: [PATCH] Add event. work in progress[2] --- res/values/strings.xml | 2 +- src/ro/ieval/unical/AddEventActivity.java | 33 ++++++-------------- src/ro/ieval/unical/AddEventTabListener.java | 16 +++++++++- src/ro/ieval/unical/Event.java | 2 ++ 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 6e33421..229caf7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -25,7 +25,7 @@ Friday Saturday Save - Basic info + Basic Details Other Event Name diff --git a/src/ro/ieval/unical/AddEventActivity.java b/src/ro/ieval/unical/AddEventActivity.java index 6284b73..c3d3620 100644 --- a/src/ro/ieval/unical/AddEventActivity.java +++ b/src/ro/ieval/unical/AddEventActivity.java @@ -12,13 +12,11 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.widget.DatePicker; -import android.widget.EditText; -import android.widget.TextView; -import android.widget.TimePicker; +import android.widget.*; public final class AddEventActivity extends Activity implements OnDateSetListener, OnTimeSetListener{ private TextView dateTimeTextView; + private Event tempEvent=new Event(); @Override protected void onCreate(final Bundle savedInstanceState) { @@ -46,9 +44,9 @@ public final class AddEventActivity extends Activity implements OnDateSetListene b3.putInt(TrivialFragment.ARGUMENT_LAYOUT, R.layout.add_event_other_tab); f3.setArguments(b3); - t1.setTabListener(new AddEventTabListener(f1)); - t2.setTabListener(new AddEventTabListener(f2)); - t3.setTabListener(new AddEventTabListener(f3)); + t1.setTabListener(new AddEventTabListener(f1,tempEvent,0)); + t2.setTabListener(new AddEventTabListener(f2,tempEvent,1)); + t3.setTabListener(new AddEventTabListener(f3,tempEvent,2)); actionBar.addTab(t1); actionBar.addTab(t2); @@ -69,29 +67,16 @@ public final class AddEventActivity extends Activity implements OnDateSetListene finish(); return true; case R.id.save: - Event e = getEvent(this); + //TODO Save event + Toast toast = Toast.makeText(getApplicationContext(),"Event saved!",Toast.LENGTH_LONG); + toast.show(); + finish(); return true; default: return false; } } - private Event getEvent(final Activity v) { - //TODO get all information - final long _id=23;//blatul olimpic - final String organizer=""; - final String title=""; - final String eventLocation=""; - final String description=""; - final int eventColor=0; - final long dtstart=0; - final long dtend=0; - final long calendarID = 0; - System.out.print(title + description); - Event ret = new Event(_id,organizer,title,eventLocation,description,eventColor,dtstart,dtend,calendarID); - return ret; - } - public void showDateTimePickerDialog(final View v) { dateTimeTextView=(TextView) v; if(v.getId()==R.id.date_start || v.getId()==R.id.date_end || v.getId() == R.id.repeat_until) diff --git a/src/ro/ieval/unical/AddEventTabListener.java b/src/ro/ieval/unical/AddEventTabListener.java index ea67b63..b38779c 100644 --- a/src/ro/ieval/unical/AddEventTabListener.java +++ b/src/ro/ieval/unical/AddEventTabListener.java @@ -7,9 +7,13 @@ import android.app.FragmentTransaction; public class AddEventTabListener implements ActionBar.TabListener { public Fragment fragment; + private Event ev; + int tabId; - public AddEventTabListener(final Fragment fragment) { + public AddEventTabListener(final Fragment fragment,Event e,int tabId) { this.fragment = fragment; + this.ev = e; + this.tabId=tabId; } @Override @@ -19,6 +23,16 @@ public class AddEventTabListener implements ActionBar.TabListener { @Override public void onTabUnselected(final Tab tab, final FragmentTransaction ft) { + switch (tabId) { + case 0: + ev.title=fragment.getView().findViewById(R.id.eventtitle).toString(); + break; + case 1: + ev.description=fragment.getView().findViewById(R.id.description).toString(); + break; + case 2: + break; + } ft.remove(fragment); } diff --git a/src/ro/ieval/unical/Event.java b/src/ro/ieval/unical/Event.java index 748d42e..8839838 100644 --- a/src/ro/ieval/unical/Event.java +++ b/src/ro/ieval/unical/Event.java @@ -55,6 +55,8 @@ final class Event implements Parcelable{ /** Calendar ID */ public long calendarID; + public Event() {} + public Event(final long _id, final String organizer, final String title, final String eventLocation, final String description, final int eventColor, final long dtstart, final long dtend, final long calendarID) { this._id=_id; this.organizer=organizer; -- 2.39.2