Commit | Line | Data |
---|---|---|
724f9857 MG |
1 | package ro.ieval.unical; |
2 | ||
3 | import android.app.Fragment; | |
4 | import android.os.Bundle; | |
408a6278 | 5 | import android.text.InputType; |
724f9857 MG |
6 | import android.view.LayoutInflater; |
7 | import android.view.View; | |
8 | import android.view.ViewGroup; | |
408a6278 PT |
9 | import android.widget.AdapterView; |
10 | import android.widget.AdapterView.OnItemSelectedListener; | |
306c1a65 | 11 | import android.widget.CompoundButton; |
408a6278 | 12 | import android.widget.EditText; |
361c6a28 | 13 | import android.widget.LinearLayout; |
306c1a65 MG |
14 | import android.widget.Spinner; |
15 | import android.widget.Switch; | |
16 | import android.widget.CompoundButton.OnCheckedChangeListener; | |
724f9857 MG |
17 | |
18 | public final class TrivialFragment extends Fragment { | |
88ba7fcf | 19 | public static final String ARGUMENT_LAYOUT="layout"; |
724f9857 MG |
20 | |
21 | @Override | |
22 | public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { | |
361c6a28 | 23 | |
306c1a65 | 24 | final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false); |
361c6a28 PT |
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 | ||
306c1a65 MG |
31 | repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() { |
32 | @Override | |
33 | public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { | |
34 | if(isChecked) { | |
361c6a28 | 35 | Utils.setEnabledRecursively(ll, true); |
408a6278 PT |
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 | }); | |
306c1a65 | 62 | }else { |
361c6a28 | 63 | Utils.setEnabledRecursively(ll, false); |
306c1a65 MG |
64 | } |
65 | } | |
66 | }); | |
67 | } | |
68 | return view; | |
69 | } | |
724f9857 | 70 | } |