Edit event. work in progress[3]
[unical.git] / src / ro / ieval / unical / AddEventTabListener.java
index b38779cfd138babeff7db32598e0f491ab913bb0..e9b840f2927bff57ead35b411887e3e39653b321 100644 (file)
@@ -4,11 +4,18 @@ import android.app.ActionBar;
 import android.app.ActionBar.Tab;
 import android.app.Fragment;
 import android.app.FragmentTransaction;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 public class AddEventTabListener implements ActionBar.TabListener {
-       public Fragment fragment;
+       private Fragment fragment;
     private Event ev;
-    int tabId;
+       private boolean isAdded = false;
+    private int tabId;
 
        public AddEventTabListener(final Fragment fragment,Event e,int tabId) {
                this.fragment = fragment;
@@ -18,7 +25,12 @@ public class AddEventTabListener implements ActionBar.TabListener {
 
        @Override
        public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
-               ft.replace(R.id.fragment_container, fragment);
+               if(isAdded)
+                       ft.attach(fragment);
+               else {
+                       isAdded = true;
+                       ft.add(android.R.id.content, fragment);
+               }
        }
 
        @Override
@@ -26,6 +38,19 @@ public class AddEventTabListener implements ActionBar.TabListener {
         switch (tabId) {
             case 0:
                 ev.title=fragment.getView().findViewById(R.id.eventtitle).toString();
+                String start=fragment.getView().findViewById(R.id.date_start).toString()+ " " +
+                             fragment.getView().findViewById(R.id.time_start).toString();
+                String end=fragment.getView().findViewById(R.id.date_end).toString()+ " " +
+                             fragment.getView().findViewById(R.id.time_end).toString();
+                try {
+                    Date s=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(start);
+                    Date e=new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(end);
+                    ev.dtstart=s.getTime();
+                    ev.dtend=s.getTime();
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+
                 break;
             case 1:
                 ev.description=fragment.getView().findViewById(R.id.description).toString();
@@ -33,12 +58,11 @@ public class AddEventTabListener implements ActionBar.TabListener {
             case 2:
                 break;
         }
-               ft.remove(fragment);
+               ft.detach(fragment);
        }
 
        @Override
        public void onTabReselected(final Tab tab, final FragmentTransaction ft) {
-               // TODO Auto-generated method stub
-
+               // do nothing
        }
 }
This page took 0.010593 seconds and 4 git commands to generate.