Removes final atribute from Event fields. Fixes a bug when setting the date
[unical.git] / src / ro / ieval / unical / TrivialFragment.java
CommitLineData
724f9857
MG
1package ro.ieval.unical;
2
5835912b 3import android.app.ActionBar;
724f9857 4import android.app.Fragment;
5835912b 5import android.app.FragmentTransaction;
724f9857
MG
6import android.os.Bundle;
7import android.view.LayoutInflater;
8import android.view.View;
9import android.view.ViewGroup;
408a6278 10import android.widget.AdapterView;
306c1a65 11import android.widget.CompoundButton;
361c6a28 12import android.widget.LinearLayout;
306c1a65
MG
13import android.widget.Spinner;
14import android.widget.Switch;
724f9857
MG
15
16public final class TrivialFragment extends Fragment {
dfc674f6 17 private static class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{
f580909c 18 private final View repeatCount;
0dde5456
MG
19 private final View repeatUntil;
20
21 public OnItemSelectedListener(final View repeatCount, final View repeatUntil) {
dfc674f6 22 this.repeatCount=repeatCount;
0dde5456 23 this.repeatUntil=repeatUntil;
dfc674f6
MG
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);
0dde5456 31 repeatUntil.setVisibility(View.GONE);
dfc674f6
MG
32 break;
33 case 1:
34 repeatCount.setVisibility(View.GONE);
0dde5456 35 repeatUntil.setVisibility(View.VISIBLE);
dfc674f6
MG
36 break;
37 case 2:
38 repeatCount.setVisibility(View.VISIBLE);
0dde5456 39 repeatUntil.setVisibility(View.GONE);
dfc674f6
MG
40 break;
41 default:
42 }
5835912b 43 }
dfc674f6
MG
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);
0dde5456 61 repeatType.setOnItemSelectedListener(new OnItemSelectedListener(root.findViewById(R.id.repeat_count),root.findViewById(R.id.repeat_until)));
dfc674f6
MG
62 }else {
63 Utils.setEnabledRecursively(layout, false);
64 }
65 }
66 }
67
88ba7fcf 68 public static final String ARGUMENT_LAYOUT="layout";
724f9857
MG
69
70 @Override
71 public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
361c6a28 72
306c1a65 73 final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false);
dfc674f6 74 final LinearLayout layout = (LinearLayout) view.findViewById(R.id.repeat_layout);
361c6a28 75
dfc674f6 76 if(layout != null){
361c6a28 77 final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
dfc674f6 78 Utils.setEnabledRecursively(layout, false);
361c6a28 79
dfc674f6 80 repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener(layout, view));
306c1a65
MG
81 }
82 return view;
83 }
724f9857 84}
This page took 0.01493 seconds and 4 git commands to generate.