1 package ro
.ieval
.unical
;
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
;
14 public final class TrivialFragment
extends Fragment
{
15 private static class OnItemSelectedListener
implements android
.widget
.AdapterView
.OnItemSelectedListener
{
16 private final View repeatCount
;
17 private final View repeatUntil
;
19 public OnItemSelectedListener(final View repeatCount
, final View repeatUntil
) {
20 this.repeatCount
=repeatCount
;
21 this.repeatUntil
=repeatUntil
;
25 public void onItemSelected(final AdapterView
<?
> whatever
, final View ignored
, final int pos
, final long id
) {
28 repeatCount
.setVisibility(View
.GONE
);
29 repeatUntil
.setVisibility(View
.GONE
);
32 repeatCount
.setVisibility(View
.GONE
);
33 repeatUntil
.setVisibility(View
.VISIBLE
);
36 repeatCount
.setVisibility(View
.VISIBLE
);
37 repeatUntil
.setVisibility(View
.GONE
);
43 @Override public void onNothingSelected(final AdapterView
<?
> arg0
) { /* do nothing */ }
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
){
55 public void onCheckedChanged(final CompoundButton buttonView
, final boolean isChecked
) {
57 Utils
.setEnabledRecursively(layout
, true);
58 final Spinner repeatType
= (Spinner
) root
.findViewById(R
.id
.repeat_type
);
59 repeatType
.setOnItemSelectedListener(new OnItemSelectedListener(root
.findViewById(R
.id
.repeat_count
),root
.findViewById(R
.id
.repeat_until
)));
61 Utils
.setEnabledRecursively(layout
, false);
66 public static final String ARGUMENT_LAYOUT
="layout";
69 public View
onCreateView(final LayoutInflater inflater
, final ViewGroup container
, final Bundle savedInstanceState
) {
71 final View view
=inflater
.inflate(getArguments().getInt(ARGUMENT_LAYOUT
), container
, false);
72 final LinearLayout layout
= (LinearLayout
) view
.findViewById(R
.id
.repeat_layout
);
75 final Switch repeatSwitch
= (Switch
) view
.findViewById(R
.id
.repeat_switch
);
76 Utils
.setEnabledRecursively(layout
, false);
78 repeatSwitch
.setOnCheckedChangeListener(new OnCheckedChangeListener(layout
, view
));