Add event work in progress
[unical.git] / src / ro / ieval / unical / TrivialFragment.java
index 0932a4a727843e26076b2e45f5bf62a6d1467cb2..55e5da177b9c56cf58347120738d9d70b5169d13 100644 (file)
@@ -2,10 +2,15 @@ package ro.ieval.unical;
 
 import android.app.Fragment;
 import android.os.Bundle;
+import android.text.InputType;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
 import android.widget.CompoundButton;
+import android.widget.EditText;
+import android.widget.LinearLayout;
 import android.widget.Spinner;
 import android.widget.Switch;
 import android.widget.CompoundButton.OnCheckedChangeListener;
@@ -15,17 +20,47 @@ public final class TrivialFragment extends Fragment {
 
        @Override
     public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
+               
                final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false);
-               final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
-               if(repeatSwitch != null){
-                       final Spinner repeatSpinner = (Spinner) view.findViewById(R.id.repeat_spinner);
+               final LinearLayout ll = (LinearLayout) view.findViewById(R.id.repeat_layout);
+               
+               if(ll != null){
+                       final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
+                       Utils.setEnabledRecursively(ll, false);
+                       
                        repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                                @Override
                                public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
                                        if(isChecked) {
-                                               repeatSpinner.setEnabled(true);
+                                               Utils.setEnabledRecursively(ll, true);
+                                               Spinner repeatType = (Spinner) view.findViewById(R.id.repeat_type);
+                                               final EditText repeatCount = (EditText) view.findViewById(R.id.repeat_count);
+                                               
+                                               repeatType.setOnItemSelectedListener(new OnItemSelectedListener() {
+
+                                                       @Override
+                                                       public void onItemSelected(AdapterView<?> arg0,
+                                                                       View arg1, int arg2, long arg3) {
+                                                               if(arg2==1) {
+                                                                       //TODO adauga un date picker
+                                                                       //TODO sterge repeatCount
+                                                                       repeatCount.setVisibility(EditText.GONE);
+                                                               }else if(arg2==2) {
+                                                                       repeatCount.setVisibility(EditText.VISIBLE);
+                                                               }else {
+                                                                       //TODO sterge repeatCount
+                                                                       repeatCount.setVisibility(EditText.GONE);
+                                                               }
+                                                               
+                                                       }
+
+                                                       @Override
+                                                       public void onNothingSelected(AdapterView<?> arg0) {
+                                                               
+                                                       }
+                                               });
                                        }else {
-                                               repeatSpinner.setEnabled(false);
+                                               Utils.setEnabledRecursively(ll, false);
                                        }
                                }
                        });
This page took 0.01107 seconds and 4 git commands to generate.