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