1 package ro
.ieval
.unical
;
3 import android
.app
.ActionBar
;
4 import android
.app
.Fragment
;
5 import android
.app
.FragmentTransaction
;
6 import android
.os
.Bundle
;
7 import android
.view
.LayoutInflater
;
8 import android
.view
.View
;
9 import android
.view
.ViewGroup
;
10 import android
.widget
.AdapterView
;
11 import android
.widget
.CompoundButton
;
12 import android
.widget
.LinearLayout
;
13 import android
.widget
.Spinner
;
14 import android
.widget
.Switch
;
16 public final class TrivialFragment
extends Fragment
{
17 private static class OnItemSelectedListener
implements android
.widget
.AdapterView
.OnItemSelectedListener
{
18 private final View repeatCount
;
19 private final View repeatUntil
;
21 public OnItemSelectedListener(final View repeatCount
, final View repeatUntil
) {
22 this.repeatCount
=repeatCount
;
23 this.repeatUntil
=repeatUntil
;
27 public void onItemSelected(final AdapterView
<?
> whatever
, final View ignored
, final int pos
, final long id
) {
30 repeatCount
.setVisibility(View
.GONE
);
31 repeatUntil
.setVisibility(View
.GONE
);
34 repeatCount
.setVisibility(View
.GONE
);
35 repeatUntil
.setVisibility(View
.VISIBLE
);
38 repeatCount
.setVisibility(View
.VISIBLE
);
39 repeatUntil
.setVisibility(View
.GONE
);
45 @Override public void onNothingSelected(final AdapterView
<?
> arg0
) { /* do nothing */ }
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
){
57 public void onCheckedChanged(final CompoundButton buttonView
, final boolean isChecked
) {
59 Utils
.setEnabledRecursively(layout
, true);
60 final Spinner repeatType
= (Spinner
) root
.findViewById(R
.id
.repeat_type
);
61 repeatType
.setOnItemSelectedListener(new OnItemSelectedListener(root
.findViewById(R
.id
.repeat_count
),root
.findViewById(R
.id
.repeat_until
)));
63 Utils
.setEnabledRecursively(layout
, false);
68 public static final String ARGUMENT_LAYOUT
="layout";
71 public View
onCreateView(final LayoutInflater inflater
, final ViewGroup container
, final Bundle savedInstanceState
) {
73 final View view
=inflater
.inflate(getArguments().getInt(ARGUMENT_LAYOUT
), container
, false);
74 final LinearLayout layout
= (LinearLayout
) view
.findViewById(R
.id
.repeat_layout
);
77 final Switch repeatSwitch
= (Switch
) view
.findViewById(R
.id
.repeat_switch
);
78 Utils
.setEnabledRecursively(layout
, false);
80 repeatSwitch
.setOnCheckedChangeListener(new OnCheckedChangeListener(layout
, view
));