Search in sources :

Example 1 with CustomAnimation2

use of com.chad.baserecyclerviewadapterhelper.animator.CustomAnimation2 in project BaseRecyclerViewAdapterHelper by CymChad.

the class AnimationUseActivity method initMenu.

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

        @Override
        public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
            switch(position) {
                case 0:
                    mAnimationAdapter.setAnimationWithDefault(BaseQuickAdapter.AnimationType.AlphaIn);
                    break;
                case 1:
                    mAnimationAdapter.setAnimationWithDefault(BaseQuickAdapter.AnimationType.ScaleIn);
                    break;
                case 2:
                    mAnimationAdapter.setAnimationWithDefault(BaseQuickAdapter.AnimationType.SlideInBottom);
                    break;
                case 3:
                    mAnimationAdapter.setAnimationWithDefault(BaseQuickAdapter.AnimationType.SlideInLeft);
                    break;
                case 4:
                    mAnimationAdapter.setAnimationWithDefault(BaseQuickAdapter.AnimationType.SlideInRight);
                    break;
                case 5:
                    mAnimationAdapter.setAdapterAnimation(new CustomAnimation1());
                    break;
                case 6:
                    mAnimationAdapter.setAdapterAnimation(new CustomAnimation2());
                    break;
                default:
                    break;
            }
            mRecyclerView.setAdapter(mAnimationAdapter);
        }
    });
    // init firstOnly state
    mAnimationAdapter.setAnimationFirstOnly(false);
    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.setAnimationFirstOnly(true);
            } else {
                mAnimationAdapter.setAnimationFirstOnly(false);
            }
            mAnimationAdapter.notifyDataSetChanged();
        }
    });
}
Also used : MaterialSpinner(com.jaredrummler.materialspinner.MaterialSpinner) CustomAnimation1(com.chad.baserecyclerviewadapterhelper.animator.CustomAnimation1) CustomAnimation2(com.chad.baserecyclerviewadapterhelper.animator.CustomAnimation2) SwitchButton(com.kyleduo.switchbutton.SwitchButton) CompoundButton(android.widget.CompoundButton)

Aggregations

CompoundButton (android.widget.CompoundButton)1 CustomAnimation1 (com.chad.baserecyclerviewadapterhelper.animator.CustomAnimation1)1 CustomAnimation2 (com.chad.baserecyclerviewadapterhelper.animator.CustomAnimation2)1 MaterialSpinner (com.jaredrummler.materialspinner.MaterialSpinner)1 SwitchButton (com.kyleduo.switchbutton.SwitchButton)1