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