Search in sources :

Example 16 with CompoundButton

use of android.widget.CompoundButton in project CountdownView by iwgang.

the class DynamicShowActivity method handlerCheckBoxSel.

private void handlerCheckBoxSel() {
    final CheckBox cbDay = (CheckBox) findViewById(R.id.cb_day);
    final CheckBox cbHour = (CheckBox) findViewById(R.id.cb_hour);
    final CheckBox cbMinute = (CheckBox) findViewById(R.id.cb_minute);
    final CheckBox cbSecond = (CheckBox) findViewById(R.id.cb_second);
    final CheckBox cbMillisecond = (CheckBox) findViewById(R.id.cb_millisecond);
    cbDay.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            DynamicShowActivity.this.isShowDay = isChecked;
        }
    });
    cbHour.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            DynamicShowActivity.this.isShowHour = isChecked;
        }
    });
    cbMinute.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            DynamicShowActivity.this.isShowMinute = isChecked;
        }
    });
    cbSecond.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            DynamicShowActivity.this.isShowSecond = isChecked;
            if (!isChecked && DynamicShowActivity.this.isShowMillisecond) {
                cbMillisecond.setChecked(false);
            }
        }
    });
    cbMillisecond.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            DynamicShowActivity.this.isShowMillisecond = isChecked;
            if (isChecked && !DynamicShowActivity.this.isShowSecond) {
                cbSecond.setChecked(true);
            }
        }
    });
}
Also used : CheckBox(android.widget.CheckBox) CompoundButton(android.widget.CompoundButton)

Example 17 with CompoundButton

use of android.widget.CompoundButton in project CountdownView by iwgang.

the class DynamicShowActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dynamic);
    mCvCountdownViewTest = (CountdownView) findViewById(R.id.cv_countdownViewTest);
    mCvCountdownViewTestHasBg = (CountdownView) findViewById(R.id.cv_countdownViewTestHasBg);
    mLlBackgroundConfigContainer = findViewById(R.id.ll_backgroundConfigContainer);
    mLlConvertDaysToHoursContainer = findViewById(R.id.ll_convertDaysToHoursContainer);
    mCvCountdownViewTest.start(TIME);
    findViewById(R.id.btn_theme1).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            if (hasBackgroundCountdownView) {
                DynamicConfig.BackgroundInfo backgroundInfo = new DynamicConfig.BackgroundInfo();
                backgroundInfo.setColor(0xFFFF54BC).setSize(30f).setRadius(0f).setShowTimeBgDivisionLine(false);
                dynamicConfigBuilder.setTimeTextSize(15).setTimeTextColor(0xFFFFFFFF).setTimeTextBold(true).setSuffixTextColor(0xFF000000).setSuffixTextSize(15).setBackgroundInfo(backgroundInfo).setShowDay(false).setShowHour(true).setShowMinute(true).setShowSecond(true).setShowMillisecond(true);
            } else {
                dynamicConfigBuilder.setTimeTextSize(35).setTimeTextColor(0xFFFF5000).setTimeTextBold(true).setSuffixTextColor(0xFFFF5000).setSuffixTextSize(30).setSuffixTextBold(false).setSuffix(":").setSuffixMillisecond(// Remove millisecond suffix
                "").setSuffixGravity(DynamicConfig.SuffixGravity.CENTER).setShowDay(false).setShowHour(false).setShowMinute(true).setShowSecond(true).setShowMillisecond(true);
            }
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_theme2).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            if (hasBackgroundCountdownView) {
                DynamicConfig.BackgroundInfo backgroundInfo = new DynamicConfig.BackgroundInfo();
                backgroundInfo.setColor(0xFFFF5000).setSize(60f).setRadius(30f).setShowTimeBgDivisionLine(false);
                dynamicConfigBuilder.setTimeTextSize(42).setTimeTextColor(0xFFFFFFFF).setTimeTextBold(true).setSuffixTextColor(0xFF000000).setSuffixTextSize(42).setSuffixTextBold(true).setBackgroundInfo(backgroundInfo).setShowDay(false).setShowHour(true).setShowMinute(true).setShowSecond(true).setShowMillisecond(false);
            } else {
                dynamicConfigBuilder.setTimeTextSize(60).setTimeTextColor(0xFF444444).setTimeTextBold(false).setSuffixTextColor(0xFF444444).setSuffixTextSize(20).setSuffixTextBold(false).setSuffixMinute("m").setSuffixMinuteLeftMargin(5).setSuffixMinuteRightMargin(10).setSuffixSecond("s").setSuffixSecondLeftMargin(5).setSuffixGravity(DynamicConfig.SuffixGravity.BOTTOM).setShowDay(false).setShowHour(false).setShowMinute(true).setShowSecond(true).setShowMillisecond(false);
            }
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_theme3).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            if (hasBackgroundCountdownView) {
                DynamicConfig.BackgroundInfo backgroundInfo = new DynamicConfig.BackgroundInfo();
                backgroundInfo.setColor(0xFF444444).setSize(40f).setRadius(3f).setShowTimeBgDivisionLine(true).setDivisionLineColor(Color.parseColor("#30FFFFFF")).setDivisionLineSize(1f);
                dynamicConfigBuilder.setTimeTextSize(22).setTimeTextColor(0xFFFFFFFF).setTimeTextBold(true).setSuffixTextColor(0xFF000000).setSuffixTextSize(18).setSuffixTextBold(true).setBackgroundInfo(backgroundInfo).setShowDay(true).setShowHour(true).setShowMinute(true).setShowSecond(true).setShowMillisecond(true);
            } else {
                dynamicConfigBuilder.setTimeTextSize(22).setTimeTextColor(0xFF000000).setTimeTextBold(false).setSuffixTextColor(0xFF000000).setSuffixTextSize(12).setSuffixTextBold(false).setSuffixDay("天").setSuffixHour("小时").setSuffixMinute("分钟").setSuffixSecond("秒").setSuffixMillisecond("毫秒").setSuffixGravity(DynamicConfig.SuffixGravity.TOP).setShowDay(true).setShowHour(true).setShowMinute(true).setShowSecond(true).setShowMillisecond(true);
            }
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_timeTextSizePlus).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setTimeTextSize(++timeTextSize);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_timeTextSizeSubtract).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (timeTextSize == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setTimeTextSize(--timeTextSize);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_modTimeTextColor).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ColorPicker picker = new ColorPicker(DynamicShowActivity.this);
            picker.setOnColorPickListener(new ColorPicker.OnColorPickListener() {

                @Override
                public void onColorPicked(int pickedColor) {
                    DynamicConfig dynamicConfig = new DynamicConfig.Builder().setTimeTextColor(pickedColor).build();
                    if (hasBackgroundCountdownView) {
                        mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
                    } else {
                        mCvCountdownViewTest.dynamicShow(dynamicConfig);
                    }
                }
            });
            picker.show();
        }
    });
    findViewById(R.id.btn_suffixTextSizePlus).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setSuffixTextSize(++suffixTextSize);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_suffixTextSizeSubtract).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (timeTextSize == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setSuffixTextSize(--suffixTextSize);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_modSuffixTextColor).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ColorPicker picker = new ColorPicker(DynamicShowActivity.this);
            picker.setOnColorPickListener(new ColorPicker.OnColorPickListener() {

                @Override
                public void onColorPicked(int pickedColor) {
                    DynamicConfig dynamicConfig = new DynamicConfig.Builder().setSuffixTextColor(pickedColor).build();
                    if (hasBackgroundCountdownView) {
                        mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
                    } else {
                        mCvCountdownViewTest.dynamicShow(dynamicConfig);
                    }
                }
            });
            picker.show();
        }
    });
    findViewById(R.id.btn_suffixGravityTop).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig dynamicConfig = new DynamicConfig.Builder().setSuffixGravity(DynamicConfig.SuffixGravity.TOP).build();
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfig);
            }
        }
    });
    findViewById(R.id.btn_suffixGravityCenter).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig dynamicConfig = new DynamicConfig.Builder().setSuffixGravity(DynamicConfig.SuffixGravity.CENTER).build();
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfig);
            }
        }
    });
    findViewById(R.id.btn_suffixGravityBottom).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig dynamicConfig = new DynamicConfig.Builder().setSuffixGravity(DynamicConfig.SuffixGravity.BOTTOM).build();
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfig);
            }
        }
    });
    findViewById(R.id.btn_refTimeShow).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isShowDay && !isShowHour && !isShowMinute && !isShowSecond && !isShowMillisecond) {
                Toast.makeText(DynamicShowActivity.this, "Select at least one item", Toast.LENGTH_LONG).show();
                return;
            }
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setShowDay(isShowDay).setShowHour(isShowHour).setShowMinute(isShowMinute).setShowSecond(isShowSecond).setShowMillisecond(isShowMillisecond);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_bgSizePlus).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setSize(++timeBgSize));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    findViewById(R.id.btn_bgSizeSubtract).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (timeBgSize == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setSize(--timeBgSize));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    findViewById(R.id.btn_modBgColor).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ColorPicker picker = new ColorPicker(DynamicShowActivity.this);
            picker.setOnColorPickListener(new ColorPicker.OnColorPickListener() {

                @Override
                public void onColorPicked(int pickedColor) {
                    DynamicConfig dynamicConfig = new DynamicConfig.Builder().setBackgroundInfo(new DynamicConfig.BackgroundInfo().setColor(pickedColor)).build();
                    mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
                }
            });
            picker.show();
        }
    });
    findViewById(R.id.btn_bgRadiusPlus).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setRadius(++bgRadius));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    findViewById(R.id.btn_bgRadiusSubtract).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (bgRadius == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setRadius(--bgRadius));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    final Button btnModBgDivisionLineColor = (Button) findViewById(R.id.btn_modBgDivisionLineColor);
    btnModBgDivisionLineColor.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ColorPicker picker = new ColorPicker(DynamicShowActivity.this);
            picker.setOnColorPickListener(new ColorPicker.OnColorPickListener() {

                @Override
                public void onColorPicked(int pickedColor) {
                    DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
                    dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgDivisionLine(true).setDivisionLineColor(pickedColor));
                    mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
                }
            });
            picker.show();
        }
    });
    ((CheckBox) findViewById(R.id.cb_bgDivisionLine)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            btnModBgDivisionLineColor.setEnabled(isChecked);
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgDivisionLine(isChecked));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    final Button btnBgBorderSizePlus = (Button) findViewById(R.id.btn_bgBorderSizePlus);
    final Button btnBgBorderSizeSubtract = (Button) findViewById(R.id.btn_bgBorderSizeSubtract);
    final Button btnBgBorderRadiusPlus = (Button) findViewById(R.id.btn_bgBorderRadiusPlus);
    final Button btnBgBorderRadiusSubtract = (Button) findViewById(R.id.btn_bgBorderRadiusSubtract);
    btnBgBorderSizePlus.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderSize(++bgBorderSize));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    btnBgBorderSizeSubtract.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (bgBorderSize == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderSize(--bgBorderSize));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    btnBgBorderRadiusPlus.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderRadius(++bgBorderRadius));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    btnBgBorderRadiusSubtract.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (bgBorderRadius == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderRadius(--bgBorderRadius));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    final Button btnModBgBorderColor = (Button) findViewById(R.id.btn_modBgBorderColor);
    btnModBgBorderColor.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ColorPicker picker = new ColorPicker(DynamicShowActivity.this);
            picker.setOnColorPickListener(new ColorPicker.OnColorPickListener() {

                @Override
                public void onColorPicked(int pickedColor) {
                    DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
                    dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderColor(pickedColor));
                    mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
                }
            });
            picker.show();
        }
    });
    ((CheckBox) findViewById(R.id.cb_bgBorder)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            btnModBgBorderColor.setEnabled(isChecked);
            btnBgBorderSizePlus.setEnabled(isChecked);
            btnBgBorderSizeSubtract.setEnabled(isChecked);
            btnBgBorderRadiusPlus.setEnabled(isChecked);
            btnBgBorderRadiusSubtract.setEnabled(isChecked);
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(isChecked));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    ((CheckBox) findViewById(R.id.cb_bgBorder)).setChecked(false);
    final EditText etSuffixDay = (EditText) findViewById(R.id.et_suffixDay);
    final EditText etSuffixHour = (EditText) findViewById(R.id.et_suffixHour);
    final EditText etSuffixMinute = (EditText) findViewById(R.id.et_suffixMinute);
    final EditText etSuffixSecond = (EditText) findViewById(R.id.et_suffixSecond);
    final EditText etSuffixMillisecond = (EditText) findViewById(R.id.et_suffixMillisecond);
    findViewById(R.id.btm_refSuffix).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setSuffixDay(etSuffixDay.getText().toString()).setSuffixHour(etSuffixHour.getText().toString()).setSuffixMinute(etSuffixMinute.getText().toString()).setSuffixSecond(etSuffixSecond.getText().toString()).setSuffixMillisecond(etSuffixMillisecond.getText().toString());
            mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    ((CheckBox) findViewById(R.id.cb_hasBackground)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            hasBackgroundCountdownView = isChecked;
            mLlBackgroundConfigContainer.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            mCvCountdownViewTest.setVisibility(!isChecked ? View.VISIBLE : View.GONE);
            mCvCountdownViewTestHasBg.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            if (isChecked) {
                mCvCountdownViewTest.stop();
                mCvCountdownViewTestHasBg.start(TIME);
                mLlConvertDaysToHoursContainer.setVisibility(View.GONE);
            } else {
                mCvCountdownViewTestHasBg.stop();
                mCvCountdownViewTest.start(TIME);
                mLlConvertDaysToHoursContainer.setVisibility(View.VISIBLE);
            }
        }
    });
    final Button btnConvertDaysToHours = (Button) findViewById(R.id.btn_convertDaysToHours);
    findViewById(R.id.btn_convertDaysToHours).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            isConvertDaysToHours = !isConvertDaysToHours;
            btnConvertDaysToHours.setText(isConvertDaysToHours ? "转换" : "不转换");
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setConvertDaysToHours(isConvertDaysToHours);
            dynamicConfigBuilder.setShowDay(!isConvertDaysToHours);
            mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    handlerCheckBoxSel();
}
Also used : EditText(android.widget.EditText) ColorPicker(cn.qqtheme.framework.picker.ColorPicker) DynamicConfig(cn.iwgang.countdownview.DynamicConfig) View(android.view.View) CountdownView(cn.iwgang.countdownview.CountdownView) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) CheckBox(android.widget.CheckBox) CompoundButton(android.widget.CompoundButton)

Example 18 with CompoundButton

use of android.widget.CompoundButton in project SmartAndroidSource by jaychou2012.

the class AbstractAQuery method isChecked.

/**
	 * Get checked state of a compound button.
	 *
	 * @return checked
	 */
public boolean isChecked() {
    boolean checked = false;
    if (view instanceof CompoundButton) {
        CompoundButton cb = (CompoundButton) view;
        checked = cb.isChecked();
    }
    return checked;
}
Also used : CompoundButton(android.widget.CompoundButton)

Example 19 with CompoundButton

use of android.widget.CompoundButton in project SmartAndroidSource by jaychou2012.

the class AbstractAQuery method checked.

/**
	 * Set checked state of a compound button.
	 *
	 * @param checked state
	 * @return self
	 */
public T checked(boolean checked) {
    if (view instanceof CompoundButton) {
        CompoundButton cb = (CompoundButton) view;
        cb.setChecked(checked);
    }
    return self();
}
Also used : CompoundButton(android.widget.CompoundButton)

Example 20 with CompoundButton

use of android.widget.CompoundButton in project SlidingMenu by jfeinstein10.

the class PropertiesActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setSlidingActionBarEnabled(true);
    setContentView(R.layout.properties);
    // left and right modes
    RadioGroup mode = (RadioGroup) findViewById(R.id.mode);
    mode.check(R.id.left);
    mode.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            SlidingMenu sm = getSlidingMenu();
            switch(checkedId) {
                case R.id.left:
                    sm.setMode(SlidingMenu.LEFT);
                    sm.setShadowDrawable(R.drawable.shadow);
                    break;
                case R.id.right:
                    sm.setMode(SlidingMenu.RIGHT);
                    sm.setShadowDrawable(R.drawable.shadowright);
                    break;
                case R.id.left_right:
                    sm.setMode(SlidingMenu.LEFT_RIGHT);
                    sm.setSecondaryMenu(R.layout.menu_frame_two);
                    getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame_two, new SampleListFragment()).commit();
                    sm.setSecondaryShadowDrawable(R.drawable.shadowright);
                    sm.setShadowDrawable(R.drawable.shadow);
            }
        }
    });
    // touch mode stuff
    RadioGroup touchAbove = (RadioGroup) findViewById(R.id.touch_above);
    touchAbove.check(R.id.touch_above_full);
    touchAbove.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch(checkedId) {
                case R.id.touch_above_full:
                    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
                    break;
                case R.id.touch_above_margin:
                    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
                    break;
                case R.id.touch_above_none:
                    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
                    break;
            }
        }
    });
    // scroll scale stuff
    SeekBar scrollScale = (SeekBar) findViewById(R.id.scroll_scale);
    scrollScale.setMax(1000);
    scrollScale.setProgress(333);
    scrollScale.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            getSlidingMenu().setBehindScrollScale((float) seekBar.getProgress() / seekBar.getMax());
        }
    });
    // behind width stuff
    SeekBar behindWidth = (SeekBar) findViewById(R.id.behind_width);
    behindWidth.setMax(1000);
    behindWidth.setProgress(750);
    behindWidth.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            float percent = (float) seekBar.getProgress() / seekBar.getMax();
            getSlidingMenu().setBehindWidth((int) (percent * getSlidingMenu().getWidth()));
            getSlidingMenu().requestLayout();
        }
    });
    // shadow stuff
    CheckBox shadowEnabled = (CheckBox) findViewById(R.id.shadow_enabled);
    shadowEnabled.setChecked(true);
    shadowEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked)
                getSlidingMenu().setShadowDrawable(getSlidingMenu().getMode() == SlidingMenu.LEFT ? R.drawable.shadow : R.drawable.shadowright);
            else
                getSlidingMenu().setShadowDrawable(null);
        }
    });
    SeekBar shadowWidth = (SeekBar) findViewById(R.id.shadow_width);
    shadowWidth.setMax(1000);
    shadowWidth.setProgress(75);
    shadowWidth.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            float percent = (float) seekBar.getProgress() / (float) seekBar.getMax();
            int width = (int) (percent * (float) getSlidingMenu().getWidth());
            getSlidingMenu().setShadowWidth(width);
            getSlidingMenu().invalidate();
        }
    });
    // fading stuff
    CheckBox fadeEnabled = (CheckBox) findViewById(R.id.fade_enabled);
    fadeEnabled.setChecked(true);
    fadeEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            getSlidingMenu().setFadeEnabled(isChecked);
        }
    });
    SeekBar fadeDeg = (SeekBar) findViewById(R.id.fade_degree);
    fadeDeg.setMax(1000);
    fadeDeg.setProgress(666);
    fadeDeg.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            getSlidingMenu().setFadeDegree((float) seekBar.getProgress() / seekBar.getMax());
        }
    });
}
Also used : SlidingMenu(com.jeremyfeinstein.slidingmenu.lib.SlidingMenu) OnCheckedChangeListener(android.widget.RadioGroup.OnCheckedChangeListener) RadioGroup(android.widget.RadioGroup) SeekBar(android.widget.SeekBar) CheckBox(android.widget.CheckBox) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) CompoundButton(android.widget.CompoundButton)

Aggregations

CompoundButton (android.widget.CompoundButton)235 View (android.view.View)118 TextView (android.widget.TextView)95 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)60 ImageView (android.widget.ImageView)48 CheckBox (android.widget.CheckBox)42 AdapterView (android.widget.AdapterView)25 Button (android.widget.Button)22 DialogInterface (android.content.DialogInterface)21 LayoutInflater (android.view.LayoutInflater)20 OnClickListener (android.view.View.OnClickListener)18 Intent (android.content.Intent)17 SeekBar (android.widget.SeekBar)17 Switch (android.widget.Switch)17 SwitchCompat (android.support.v7.widget.SwitchCompat)15 AlertDialog (android.app.AlertDialog)13 ArrayList (java.util.ArrayList)12 Context (android.content.Context)11 OnClickListener (android.content.DialogInterface.OnClickListener)11 Cursor (android.database.Cursor)11