Search in sources :

Example 1 with SwitchButton

use of com.kyleduo.switchbutton.SwitchButton in project SwitchButton by kyleduo.

the class StyleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_style);
    SwitchButton disableSb = (SwitchButton) findViewById(R.id.sb_disable_control);
    SwitchButton disableNoEventSb = (SwitchButton) findViewById(R.id.sb_disable_control_no_event);
    mFlymeSb = (SwitchButton) findViewById(R.id.sb_custom_flyme);
    mMiuiSb = (SwitchButton) findViewById(R.id.sb_custom_miui);
    mCustomSb = (SwitchButton) findViewById(R.id.sb_custom);
    mDefaultSb = (SwitchButton) findViewById(R.id.sb_default);
    mSB = (SwitchButton) findViewById(R.id.sb_ios);
    disableSb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mFlymeSb.setEnabled(isChecked);
            mMiuiSb.setEnabled(isChecked);
            mCustomSb.setEnabled(isChecked);
            mDefaultSb.setEnabled(isChecked);
            mSB.setEnabled(isChecked);
        }
    });
    disableNoEventSb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mFlymeSb.setEnabled(isChecked);
            mMiuiSb.setEnabled(isChecked);
            mCustomSb.setEnabled(isChecked);
            mDefaultSb.setEnabled(isChecked);
            mSB.setEnabled(isChecked);
        }
    });
    disableNoEventSb.setCheckedImmediatelyNoEvent(false);
}
Also used : SwitchButton(com.kyleduo.switchbutton.SwitchButton) CompoundButton(android.widget.CompoundButton)

Example 2 with SwitchButton

use of com.kyleduo.switchbutton.SwitchButton in project BaseRecyclerViewAdapterHelper by CymChad.

the class AnimationUseActivity method initMenu.

private void initMenu() {
    MaterialSpinner spinner = (MaterialSpinner) findViewById(R.id.spinner);
    spinner.setItems("AlphaIn", "ScaleIn", "SlideInBottom", "SlideInLeft", "SlideInRight", "Custom");
    spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {

        @Override
        public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
            switch(position) {
                case 0:
                    mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
                    break;
                case 1:
                    mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
                    break;
                case 2:
                    mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM);
                    break;
                case 3:
                    mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT);
                    break;
                case 4:
                    mAnimationAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_RIGHT);
                    break;
                case 5:
                    mAnimationAdapter.openLoadAnimation(new CustomAnimation());
                    break;
                default:
                    break;
            }
            mRecyclerView.setAdapter(mAnimationAdapter);
        }
    });
    SwitchButton switchButton = (SwitchButton) findViewById(R.id.switch_button);
    switchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            if (isChecked) {
                mAnimationAdapter.isFirstOnly(true);
            } else {
                mAnimationAdapter.isFirstOnly(false);
            }
            mAnimationAdapter.notifyDataSetChanged();
        }
    });
}
Also used : MaterialSpinner(com.jaredrummler.materialspinner.MaterialSpinner) CustomAnimation(com.chad.baserecyclerviewadapterhelper.animation.CustomAnimation) SwitchButton(com.kyleduo.switchbutton.SwitchButton) CompoundButton(android.widget.CompoundButton)

Aggregations

CompoundButton (android.widget.CompoundButton)2 SwitchButton (com.kyleduo.switchbutton.SwitchButton)2 CustomAnimation (com.chad.baserecyclerviewadapterhelper.animation.CustomAnimation)1 MaterialSpinner (com.jaredrummler.materialspinner.MaterialSpinner)1