Edit event. work in progress[3]
[unical.git] / src / ro / ieval / unical / TrivialFragment.java
index 4a1c0b2b38a17f39b160c424e011eb9a50d2374f..54c9731d675ae6de5d3cc3b4de845829b7c5523e 100644 (file)
@@ -1,21 +1,64 @@
 package ro.ieval.unical;
 
+import android.app.ActionBar;
 import android.app.Fragment;
+import android.app.FragmentTransaction;
 import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.CompoundButton;
-import android.widget.LinearLayout;
-import android.widget.Spinner;
-import android.widget.Switch;
+import android.widget.*;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 public final class TrivialFragment extends Fragment {
+    Event ev;
+    public TrivialFragment(Event e) {
+        ev=e;
+    }
+
+    @Override
+    public void onActivityCreated (Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        switch (getArguments().getInt(ARGUMENT_LAYOUT)) {
+            case R.layout.add_event_basic_tab:
+                EditText title = (EditText) getView().findViewById(R.id.eventtitle);
+                title.setText(ev.title, TextView.BufferType.EDITABLE);
+
+                TextView tstart = (TextView) getView().findViewById(R.id.time_start);
+                TextView tend = (TextView) getView().findViewById(R.id.time_end);
+                SimpleDateFormat sf=new SimpleDateFormat("HH:MM");
+                Date d=new Date(ev.dtstart);
+                tstart.setText(sf.format(d).toString(),TextView.BufferType.NORMAL);
+                d.setTime(ev.dtend);
+                tend.setText(sf.format(d).toString(),TextView.BufferType.NORMAL);
+
+                SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
+                TextView dstart = (TextView)getView().findViewById(R.id.date_start);
+                TextView dend = (TextView)getView().findViewById(R.id.date_end);
+                d.setTime(ev.dtstart);
+                dstart.setText(sd.format(d).toString(),TextView.BufferType.NORMAL);
+                d.setTime(ev.dtend);
+                dend.setText(sd.format(d).toString(),TextView.BufferType.NORMAL);
+                break;
+            case R.layout.add_event_details_tab:
+                EditText description = (EditText) getView().findViewById(R.id.description);
+                description.setText(ev.description,TextView.BufferType.EDITABLE);
+                break;
+            case R.layout.add_event_other_tab:
+                break;
+        }
+
+    }
+
        private static class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{
                private final View repeatCount;
-               public OnItemSelectedListener(final View repeatCount) {
+               private final View repeatUntil;
+
+               public OnItemSelectedListener(final View repeatCount, final View repeatUntil) {
                        this.repeatCount=repeatCount;
+                       this.repeatUntil=repeatUntil;
                }
 
                @Override
@@ -23,16 +66,19 @@ public final class TrivialFragment extends Fragment {
                        switch(pos){
                        case 0:
                                repeatCount.setVisibility(View.GONE);
+                               repeatUntil.setVisibility(View.GONE);
                                break;
                        case 1:
                                repeatCount.setVisibility(View.GONE);
+                               repeatUntil.setVisibility(View.VISIBLE);
                                break;
                        case 2:
                                repeatCount.setVisibility(View.VISIBLE);
+                               repeatUntil.setVisibility(View.GONE);
                                break;
                        default:
                        }
-               }
+        }
 
                @Override public void onNothingSelected(final AdapterView<?> arg0) { /* do nothing */   }
        }
@@ -50,7 +96,7 @@ public final class TrivialFragment extends Fragment {
                        if(isChecked) {
                                Utils.setEnabledRecursively(layout, true);
                                final Spinner repeatType = (Spinner) root.findViewById(R.id.repeat_type);
-                               repeatType.setOnItemSelectedListener(new OnItemSelectedListener(root.findViewById(R.id.repeat_count)));
+                               repeatType.setOnItemSelectedListener(new OnItemSelectedListener(root.findViewById(R.id.repeat_count),root.findViewById(R.id.repeat_until)));
                        }else {
                                Utils.setEnabledRecursively(layout, false);
                        }
This page took 0.011536 seconds and 4 git commands to generate.