Search in sources :

Example 21 with CheckBox

use of android.widget.CheckBox in project material-dialogs by afollestad.

the class MaterialDialog method onItemSelected.

@Override
public boolean onItemSelected(MaterialDialog dialog, View view, int position, CharSequence text, boolean longPress) {
    if (!view.isEnabled()) {
        return false;
    }
    if (listType == null || listType == ListType.REGULAR) {
        // Default adapter, non choice mode
        if (builder.autoDismiss) {
            // If auto dismiss is enabled, dismiss the dialog when a list item is selected
            dismiss();
        }
        if (!longPress && builder.listCallback != null) {
            builder.listCallback.onSelection(this, view, position, builder.items.get(position));
        }
        if (longPress && builder.listLongCallback != null) {
            return builder.listLongCallback.onLongSelection(this, view, position, builder.items.get(position));
        }
    } else {
        // Default adapter, choice mode
        if (listType == ListType.MULTI) {
            final CheckBox cb = (CheckBox) view.findViewById(R.id.md_control);
            if (!cb.isEnabled()) {
                return false;
            }
            final boolean shouldBeChecked = !selectedIndicesList.contains(position);
            if (shouldBeChecked) {
                // Add the selection to the states first so the callback includes it (when alwaysCallMultiChoiceCallback)
                selectedIndicesList.add(position);
                if (builder.alwaysCallMultiChoiceCallback) {
                    // If the checkbox wasn't previously selected, and the callback returns true, add it to the states and check it
                    if (sendMultiChoiceCallback()) {
                        cb.setChecked(true);
                    } else {
                        // The callback cancelled selection, remove it from the states
                        selectedIndicesList.remove(Integer.valueOf(position));
                    }
                } else {
                    // The callback was not used to check if selection is allowed, just select it
                    cb.setChecked(true);
                }
            } else {
                // Remove the selection from the states first so the callback does not include it (when alwaysCallMultiChoiceCallback)
                selectedIndicesList.remove(Integer.valueOf(position));
                if (builder.alwaysCallMultiChoiceCallback) {
                    // If the checkbox was previously selected, and the callback returns true, remove it from the states and uncheck it
                    if (sendMultiChoiceCallback()) {
                        cb.setChecked(false);
                    } else {
                        // The callback cancelled unselection, re-add it to the states
                        selectedIndicesList.add(position);
                    }
                } else {
                    // The callback was not used to check if the unselection is allowed, just uncheck it
                    cb.setChecked(false);
                }
            }
        } else if (listType == ListType.SINGLE) {
            final RadioButton radio = (RadioButton) view.findViewById(R.id.md_control);
            if (!radio.isEnabled()) {
                return false;
            }
            boolean allowSelection = true;
            final int oldSelected = builder.selectedIndex;
            if (builder.autoDismiss && builder.positiveText == null) {
                // If auto dismiss is enabled, and no action button is visible to approve the selection, dismiss the dialog
                dismiss();
                // Don't allow the selection to be updated since the dialog is being dismissed anyways
                allowSelection = false;
                // Update selected index and send callback
                builder.selectedIndex = position;
                sendSingleChoiceCallback(view);
            } else if (builder.alwaysCallSingleChoiceCallback) {
                // Temporarily set the new index so the callback uses the right one
                builder.selectedIndex = position;
                // Only allow the radio button to be checked if the callback returns true
                allowSelection = sendSingleChoiceCallback(view);
                // Restore the old selected index, so the state is updated below
                builder.selectedIndex = oldSelected;
            }
            // Update the checked states
            if (allowSelection) {
                builder.selectedIndex = position;
                radio.setChecked(true);
                builder.adapter.notifyItemChanged(oldSelected);
                builder.adapter.notifyItemChanged(position);
            }
        }
    }
    return true;
}
Also used : CheckBox(android.widget.CheckBox) RadioButton(android.widget.RadioButton)

Example 22 with CheckBox

use of android.widget.CheckBox 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 23 with CheckBox

use of android.widget.CheckBox 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 24 with CheckBox

use of android.widget.CheckBox 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)

Example 25 with CheckBox

use of android.widget.CheckBox in project c-geo by just-radovan.

the class cgeoinit method init.

public void init() {
    // geocaching.com settings
    String usernameNow = prefs.getString("username", null);
    if (usernameNow != null) {
        ((EditText) findViewById(R.id.username)).setText(usernameNow);
    }
    String passwordNow = prefs.getString("password", null);
    if (usernameNow != null) {
        ((EditText) findViewById(R.id.password)).setText(passwordNow);
    }
    Button logMeIn = (Button) findViewById(R.id.log_me_in);
    logMeIn.setOnClickListener(new logIn());
    TextView legalNote = (TextView) findViewById(R.id.legal_note);
    legalNote.setClickable(true);
    legalNote.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.geocaching.com/about/termsofuse.aspx")));
        }
    });
    // gcvote settings
    String passvoteNow = prefs.getString("pass-vote", null);
    if (passvoteNow != null) {
        ((EditText) findViewById(R.id.passvote)).setText(passvoteNow);
    }
    // go4cache settings
    TextView go4cache = (TextView) findViewById(R.id.about_go4cache);
    go4cache.setClickable(true);
    go4cache.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://go4cache.com/")));
        }
    });
    CheckBox publicButton = (CheckBox) findViewById(R.id.publicloc);
    if (prefs.getInt("publicloc", 0) == 0) {
        publicButton.setChecked(false);
    } else {
        publicButton.setChecked(true);
    }
    publicButton.setOnClickListener(new cgeoChangePublic());
    // Twitter settings
    Button authorizeTwitter = (Button) findViewById(R.id.authorize_twitter);
    authorizeTwitter.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            Intent authIntent = new Intent(activity, cgeoauth.class);
            activity.startActivity(authIntent);
        }
    });
    CheckBox twitterButton = (CheckBox) findViewById(R.id.twitter_option);
    if (prefs.getInt("twitter", 0) == 0 || settings.tokenPublic == null || settings.tokenPublic.length() == 0 || settings.tokenSecret == null || settings.tokenSecret.length() == 0) {
        twitterButton.setChecked(false);
    } else {
        twitterButton.setChecked(true);
    }
    twitterButton.setOnClickListener(new cgeoChangeTwitter());
    // Signature settings
    EditText sigEdit = (EditText) findViewById(R.id.signature);
    if (sigEdit.getText().length() == 0) {
        sigEdit.setText(settings.getSignature());
    }
    Button sigBtn = (Button) findViewById(R.id.signature_help);
    sigBtn.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            warning.helpDialog(res.getString(R.string.init_signature_help_title), res.getString(R.string.init_signature_help_text));
        }
    });
    // Other settings
    CheckBox skinButton = (CheckBox) findViewById(R.id.skin);
    if (prefs.getInt("skin", 0) == 0) {
        skinButton.setChecked(false);
    } else {
        skinButton.setChecked(true);
    }
    skinButton.setOnClickListener(new cgeoChangeSkin());
    CheckBox addressButton = (CheckBox) findViewById(R.id.address);
    if (prefs.getInt("showaddress", 1) == 0) {
        addressButton.setChecked(false);
    } else {
        addressButton.setChecked(true);
    }
    addressButton.setOnClickListener(new cgeoChangeAddress());
    CheckBox captchaButton = (CheckBox) findViewById(R.id.captcha);
    if (prefs.getBoolean("showcaptcha", false) == false) {
        captchaButton.setChecked(false);
    } else {
        captchaButton.setChecked(true);
    }
    captchaButton.setOnClickListener(new cgeoChangeCaptcha());
    CheckBox useEnglishButton = (CheckBox) findViewById(R.id.useenglish);
    if (prefs.getBoolean("useenglish", false) == false) {
        useEnglishButton.setChecked(false);
    } else {
        useEnglishButton.setChecked(true);
    }
    useEnglishButton.setOnClickListener(new cgeoChangeUseEnglish());
    CheckBox excludeButton = (CheckBox) findViewById(R.id.exclude);
    if (prefs.getInt("excludemine", 0) == 0) {
        excludeButton.setChecked(false);
    } else {
        excludeButton.setChecked(true);
    }
    excludeButton.setOnClickListener(new cgeoChangeExclude());
    CheckBox disabledButton = (CheckBox) findViewById(R.id.disabled);
    if (prefs.getInt("excludedisabled", 0) == 0) {
        disabledButton.setChecked(false);
    } else {
        disabledButton.setChecked(true);
    }
    disabledButton.setOnClickListener(new cgeoChangeDisabled());
    CheckBox offlineButton = (CheckBox) findViewById(R.id.offline);
    if (prefs.getInt("offlinemaps", 1) == 0) {
        offlineButton.setChecked(false);
    } else {
        offlineButton.setChecked(true);
    }
    offlineButton.setOnClickListener(new cgeoChangeOffline());
    CheckBox autoloadButton = (CheckBox) findViewById(R.id.autoload);
    if (prefs.getInt("autoloaddesc", 0) == 0) {
        autoloadButton.setChecked(false);
    } else {
        autoloadButton.setChecked(true);
    }
    autoloadButton.setOnClickListener(new cgeoChangeAutoload());
    CheckBox livelistButton = (CheckBox) findViewById(R.id.livelist);
    if (prefs.getInt("livelist", 1) == 0) {
        livelistButton.setChecked(false);
    } else {
        livelistButton.setChecked(true);
    }
    livelistButton.setOnClickListener(new cgeoChangeLivelist());
    CheckBox unitsButton = (CheckBox) findViewById(R.id.units);
    if (prefs.getInt("units", cgSettings.unitsMetric) == cgSettings.unitsMetric) {
        unitsButton.setChecked(false);
    } else {
        unitsButton.setChecked(true);
    }
    unitsButton.setOnClickListener(new cgeoChangeUnits());
    CheckBox gnavButton = (CheckBox) findViewById(R.id.gnav);
    if (prefs.getInt("usegnav", 1) == 1) {
        gnavButton.setChecked(true);
    } else {
        gnavButton.setChecked(false);
    }
    gnavButton.setOnClickListener(new cgeoChangeGNav());
    CheckBox browserButton = (CheckBox) findViewById(R.id.browser);
    if (prefs.getInt("asbrowser", 1) == 0) {
        browserButton.setChecked(false);
    } else {
        browserButton.setChecked(true);
    }
    browserButton.setOnClickListener(new cgeoChangeBrowser());
    // Altitude settings
    EditText altitudeEdit = (EditText) findViewById(R.id.altitude);
    altitudeEdit.setText("" + prefs.getInt("altcorrection", 0));
    // Map source settings
    Spinner mapSourceSelector = (Spinner) findViewById(R.id.mapsource);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.map_sources, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mapSourceSelector.setAdapter(adapter);
    int mapsource = prefs.getInt("mapsource", 0);
    mapSourceSelector.setSelection(mapsource);
    mapSourceSelector.setOnItemSelectedListener(new cgeoChangeMapSource());
    EditText mfmapFileEdit = (EditText) findViewById(R.id.mapfile);
    mfmapFileEdit.setText(prefs.getString("mfmapfile", ""));
    setMapFileEditState();
    // Cache db backup
    TextView lastBackup = (TextView) findViewById(R.id.backup_last);
    File lastBackupFile = app.isRestoreFile();
    if (lastBackupFile != null) {
        lastBackup.setText(res.getString(R.string.init_backup_last) + " " + cgBase.timeOut.format(lastBackupFile.lastModified()) + ", " + cgBase.dateOut.format(lastBackupFile.lastModified()));
    } else {
        lastBackup.setText(res.getString(R.string.init_backup_last_no));
    }
}
Also used : Spinner(android.widget.Spinner) Button(android.widget.Button) TextView(android.widget.TextView) EditText(android.widget.EditText) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) CheckBox(android.widget.CheckBox) File(java.io.File)

Aggregations

CheckBox (android.widget.CheckBox)183 View (android.view.View)92 TextView (android.widget.TextView)69 CompoundButton (android.widget.CompoundButton)46 Button (android.widget.Button)43 ImageView (android.widget.ImageView)29 Intent (android.content.Intent)28 EditText (android.widget.EditText)27 AdapterView (android.widget.AdapterView)25 ListView (android.widget.ListView)20 LayoutInflater (android.view.LayoutInflater)19 DialogInterface (android.content.DialogInterface)16 RadioButton (android.widget.RadioButton)16 SuppressLint (android.annotation.SuppressLint)14 RemoteException (android.os.RemoteException)13 AlertDialog (android.app.AlertDialog)12 Paint (android.graphics.Paint)12 GridLayout (android.widget.GridLayout)12 Bundle (android.os.Bundle)11 ViewGroup (android.view.ViewGroup)11