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 public OnItemSelectedListener(final View repeatCount
) {
18 this.repeatCount
=repeatCount
;
22 public void onItemSelected(final AdapterView
<?
> whatever
, final View ignored
, final int pos
, final long id
) {
25 repeatCount
.setVisibility(View
.GONE
);
28 repeatCount
.setVisibility(View
.GONE
);
31 repeatCount
.setVisibility(View
.VISIBLE
);
37 @Override public void onNothingSelected(final AdapterView
<?
> arg0
) { /* do nothing */ }
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
){
49 public void onCheckedChanged(final CompoundButton buttonView
, final boolean 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
)));
55 Utils
.setEnabledRecursively(layout
, false);
60 public static final String ARGUMENT_LAYOUT
="layout";
63 public View
onCreateView(final LayoutInflater inflater
, final ViewGroup container
, final Bundle savedInstanceState
) {
65 final View view
=inflater
.inflate(getArguments().getInt(ARGUMENT_LAYOUT
), container
, false);
66 final LinearLayout layout
= (LinearLayout
) view
.findViewById(R
.id
.repeat_layout
);
69 final Switch repeatSwitch
= (Switch
) view
.findViewById(R
.id
.repeat_switch
);
70 Utils
.setEnabledRecursively(layout
, false);
72 repeatSwitch
.setOnCheckedChangeListener(new OnCheckedChangeListener(layout
, view
));