add event work in progress
[unical.git] / src / ro / ieval / unical / TrivialFragment.java
1 package ro.ieval.unical;
2
3 import android.app.Fragment;
4 import android.os.Bundle;
5 import android.text.InputType;
6 import android.view.LayoutInflater;
7 import android.view.View;
8 import android.view.ViewGroup;
9 import android.widget.AdapterView;
10 import android.widget.AdapterView.OnItemSelectedListener;
11 import android.widget.CompoundButton;
12 import android.widget.EditText;
13 import android.widget.LinearLayout;
14 import android.widget.Spinner;
15 import android.widget.Switch;
16 import android.widget.CompoundButton.OnCheckedChangeListener;
17
18 public final class TrivialFragment extends Fragment {
19 public static final String ARGUMENT_LAYOUT="layout";
20
21 @Override
22 public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
23
24 final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false);
25 final LinearLayout ll = (LinearLayout) view.findViewById(R.id.repeat_layout);
26
27 if(ll != null){
28 final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
29 Utils.setEnabledRecursively(ll, false);
30
31 repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
32 @Override
33 public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
34 if(isChecked) {
35 Utils.setEnabledRecursively(ll, true);
36 Spinner repeatType = (Spinner) view.findViewById(R.id.repeat_type);
37 final EditText repeatCount = new EditText(getActivity());
38 repeatCount.setInputType(InputType.TYPE_CLASS_NUMBER);
39 final LinearLayout repeatLayout = (LinearLayout) view.findViewById(R.id.repeat_count_layout);
40
41 repeatType.setOnItemSelectedListener(new OnItemSelectedListener() {
42
43 @Override
44 public void onItemSelected(AdapterView<?> arg0,
45 View arg1, int arg2, long arg3) {
46 if(arg2==1) {
47 //TODO adauga un date picker
48 //TODO sterge repeatCount
49 }else if(arg2==2) {
50 repeatLayout.addView(repeatCount);
51 }else {
52 //TODO sterge repeatCount
53 }
54
55 }
56
57 @Override
58 public void onNothingSelected(AdapterView<?> arg0) {
59
60 }
61 });
62 }else {
63 Utils.setEnabledRecursively(ll, false);
64 }
65 }
66 });
67 }
68 return view;
69 }
70 }
This page took 0.022715 seconds and 4 git commands to generate.