]> iEval git - unical.git/blob - src/ro/ieval/unical/TrivialFragment.java
Removes final atribute from Event fields. Fixes a bug when setting the date
[unical.git] / src / ro / ieval / unical / TrivialFragment.java
1 package ro.ieval.unical;
2
3 import android.app.ActionBar;
4 import android.app.Fragment;
5 import android.app.FragmentTransaction;
6 import android.os.Bundle;
7 import android.view.LayoutInflater;
8 import android.view.View;
9 import android.view.ViewGroup;
10 import android.widget.AdapterView;
11 import android.widget.CompoundButton;
12 import android.widget.LinearLayout;
13 import android.widget.Spinner;
14 import android.widget.Switch;
15
16 public final class TrivialFragment extends Fragment {
17 private static class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{
18 private final View repeatCount;
19 private final View repeatUntil;
20
21 public OnItemSelectedListener(final View repeatCount, final View repeatUntil) {
22 this.repeatCount=repeatCount;
23 this.repeatUntil=repeatUntil;
24 }
25
26 @Override
27 public void onItemSelected(final AdapterView<?> whatever, final View ignored, final int pos, final long id) {
28 switch(pos){
29 case 0:
30 repeatCount.setVisibility(View.GONE);
31 repeatUntil.setVisibility(View.GONE);
32 break;
33 case 1:
34 repeatCount.setVisibility(View.GONE);
35 repeatUntil.setVisibility(View.VISIBLE);
36 break;
37 case 2:
38 repeatCount.setVisibility(View.VISIBLE);
39 repeatUntil.setVisibility(View.GONE);
40 break;
41 default:
42 }
43 }
44
45 @Override public void onNothingSelected(final AdapterView<?> arg0) { /* do nothing */ }
46 }
47
48 private static class OnCheckedChangeListener implements android.widget.CompoundButton.OnCheckedChangeListener{
49 private final LinearLayout layout;
50 private final View root;
51 public OnCheckedChangeListener(final LinearLayout layout, final View root){
52 this.layout=layout;
53 this.root=root;
54 }
55
56 @Override
57 public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
58 if(isChecked) {
59 Utils.setEnabledRecursively(layout, true);
60 final Spinner repeatType = (Spinner) root.findViewById(R.id.repeat_type);
61 repeatType.setOnItemSelectedListener(new OnItemSelectedListener(root.findViewById(R.id.repeat_count),root.findViewById(R.id.repeat_until)));
62 }else {
63 Utils.setEnabledRecursively(layout, false);
64 }
65 }
66 }
67
68 public static final String ARGUMENT_LAYOUT="layout";
69
70 @Override
71 public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
72
73 final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false);
74 final LinearLayout layout = (LinearLayout) view.findViewById(R.id.repeat_layout);
75
76 if(layout != null){
77 final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
78 Utils.setEnabledRecursively(layout, false);
79
80 repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener(layout, view));
81 }
82 return view;
83 }
84 }
This page took 0.049733 seconds and 5 git commands to generate.