Search in sources :

Example 1 with MaterialSpinner

use of com.jaredrummler.materialspinner.MaterialSpinner 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)

Example 2 with MaterialSpinner

use of com.jaredrummler.materialspinner.MaterialSpinner in project cythara by gstraube.

the class MainActivity method setTuning.

private void setTuning() {
    final SharedPreferences preferences = getSharedPreferences(PREFS_FILE, MODE_PRIVATE);
    tuningPosition = preferences.getInt(CURRENT_TUNING, 0);
    int textColorDark = getResources().getColor(R.color.colorTextDark);
    MaterialSpinner spinner = findViewById(R.id.tuning);
    MaterialSpinnerAdapter<String> adapter = new MaterialSpinnerAdapter<>(this, Arrays.asList(getResources().getStringArray(R.array.tunings)));
    if (isDarkModeEnabled) {
        spinner.setTextColor(textColorDark);
        spinner.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));
        spinner.setTextColor(textColorDark);
        spinner.setArrowColor(textColorDark);
    }
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);
    spinner.setSelectedIndex(tuningPosition);
}
Also used : MaterialSpinner(com.jaredrummler.materialspinner.MaterialSpinner) SharedPreferences(android.content.SharedPreferences) MaterialSpinnerAdapter(com.jaredrummler.materialspinner.MaterialSpinnerAdapter)

Example 3 with MaterialSpinner

use of com.jaredrummler.materialspinner.MaterialSpinner 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

MaterialSpinner (com.jaredrummler.materialspinner.MaterialSpinner)3 CompoundButton (android.widget.CompoundButton)2 SwitchButton (com.kyleduo.switchbutton.SwitchButton)2 SharedPreferences (android.content.SharedPreferences)1 CustomAnimation (com.chad.baserecyclerviewadapterhelper.animation.CustomAnimation)1 CustomAnimation1 (com.chad.baserecyclerviewadapterhelper.animator.CustomAnimation1)1 CustomAnimation2 (com.chad.baserecyclerviewadapterhelper.animator.CustomAnimation2)1 MaterialSpinnerAdapter (com.jaredrummler.materialspinner.MaterialSpinnerAdapter)1