- private class OnCheckedChangeListener implements android.widget.CompoundButton.OnCheckedChangeListener{
- private final LinearLayout layout;
- public OnCheckedChangeListener(final LinearLayout layout){
- this.layout=layout;
- }
-
- private class OnItemSelectedListener implements android.widget.AdapterView.OnItemSelectedListener{
- private final View repeatCount;
- private final View repeatUntil;
-
- public OnItemSelectedListener(final View repeatCount, final View repeatUntil) {
- this.repeatCount=repeatCount;
- this.repeatUntil=repeatUntil;
- }
-
- @Override
- public void onItemSelected(final AdapterView<?> whatever, final View ignored, final int pos, final long id) {
- switch(pos){
- case 0:
- repeatCount.setVisibility(View.GONE);
- repeatUntil.setVisibility(View.GONE);
- break;
- case 1:
- repeatCount.setVisibility(View.GONE);
- repeatUntil.setVisibility(View.VISIBLE);
- break;
- case 2:
- repeatCount.setVisibility(View.VISIBLE);
- repeatUntil.setVisibility(View.GONE);
- break;
- default:
- }
- }
-
- @Override public void onNothingSelected(final AdapterView<?> arg0) { /* do nothing */ }
- }
-
- @Override
- public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
- if(isChecked) {
- Utils.setEnabledRecursively(layout, true);
- final Spinner repeatType = (Spinner) findViewById(R.id.repeat_type);
- repeatType.setOnItemSelectedListener(new OnItemSelectedListener(findViewById(R.id.repeat_count),findViewById(R.id.repeat_until)));
- }else {
- Utils.setEnabledRecursively(layout, false);
- }
- }
- }
-