Search in sources :

Example 86 with CompoundButton

use of android.widget.CompoundButton in project EasyRecyclerView by Jude95.

the class RefreshAndMoreActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    MenuItem item = menu.findItem(R.id.checkbox);
    CheckBox box = (CheckBox) item.getActionView();
    box.setChecked(true);
    box.setText("网络");
    box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            hasNetWork = isChecked;
        }
    });
    return true;
}
Also used : CheckBox(android.widget.CheckBox) MenuItem(android.view.MenuItem) CompoundButton(android.widget.CompoundButton)

Example 87 with CompoundButton

use of android.widget.CompoundButton in project UltimateAndroid by cymcsg.

the class CropperSample method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.cropper_activity);
    // Sets fonts for all
    Typeface mFont = Typeface.createFromAsset(getAssets(), "Roboto-Thin.ttf");
    ViewGroup root = (ViewGroup) findViewById(R.id.mylayout);
    setFont(root, mFont);
    // Initialize components of the app
    final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView);
    final SeekBar aspectRatioXSeek = (SeekBar) findViewById(R.id.aspectRatioXSeek);
    final SeekBar aspectRatioYSeek = (SeekBar) findViewById(R.id.aspectRatioYSeek);
    final ToggleButton fixedAspectRatioToggle = (ToggleButton) findViewById(R.id.fixedAspectRatioToggle);
    Spinner showGuidelinesSpin = (Spinner) findViewById(R.id.showGuidelinesSpin);
    // Sets sliders to be disabled until fixedAspectRatio is set
    aspectRatioXSeek.setEnabled(false);
    aspectRatioYSeek.setEnabled(false);
    // Set initial spinner value
    showGuidelinesSpin.setSelection(ON_TOUCH);
    //Sets the rotate button
    final Button rotateButton = (Button) findViewById(R.id.Button_rotate);
    rotateButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            cropImageView.rotateImage(ROTATE_NINETY_DEGREES);
        }
    });
    // Sets fixedAspectRatio
    fixedAspectRatioToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            cropImageView.setFixedAspectRatio(isChecked);
            if (isChecked) {
                aspectRatioXSeek.setEnabled(true);
                aspectRatioYSeek.setEnabled(true);
            } else {
                aspectRatioXSeek.setEnabled(false);
                aspectRatioYSeek.setEnabled(false);
            }
        }
    });
    // Sets initial aspect ratio to 10/10, for demonstration purposes
    cropImageView.setAspectRatio(DEFAULT_ASPECT_RATIO_VALUES, DEFAULT_ASPECT_RATIO_VALUES);
    // Sets aspectRatioX
    final TextView aspectRatioX = (TextView) findViewById(R.id.aspectRatioX);
    aspectRatioXSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar aspectRatioXSeek, int progress, boolean fromUser) {
            try {
                mAspectRatioX = progress;
                cropImageView.setAspectRatio(progress, mAspectRatioY);
                aspectRatioX.setText(" " + progress);
            } catch (IllegalArgumentException e) {
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    // Sets aspectRatioY
    final TextView aspectRatioY = (TextView) findViewById(R.id.aspectRatioY);
    aspectRatioYSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar aspectRatioYSeek, int progress, boolean fromUser) {
            try {
                mAspectRatioY = progress;
                cropImageView.setAspectRatio(mAspectRatioX, progress);
                aspectRatioY.setText(" " + progress);
            } catch (IllegalArgumentException e) {
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    // Sets up the Spinner
    showGuidelinesSpin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            cropImageView.setGuidelines(i);
        }

        public void onNothingSelected(AdapterView<?> adapterView) {
            return;
        }
    });
    final Button cropButton = (Button) findViewById(R.id.Button_crop);
    cropButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            croppedImage = cropImageView.getCroppedImage();
            ImageView croppedImageView = (ImageView) findViewById(R.id.croppedImageView);
            croppedImageView.setImageBitmap(croppedImage);
        }
    });
}
Also used : ToggleButton(android.widget.ToggleButton) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SeekBar(android.widget.SeekBar) Typeface(android.graphics.Typeface) ViewGroup(android.view.ViewGroup) Spinner(android.widget.Spinner) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) ImageView(android.widget.ImageView) CropImageView(com.marshalchen.common.uimodule.cropperimage.CropImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) CropImageView(com.marshalchen.common.uimodule.cropperimage.CropImageView) CropImageView(com.marshalchen.common.uimodule.cropperimage.CropImageView) CompoundButton(android.widget.CompoundButton)

Example 88 with CompoundButton

use of android.widget.CompoundButton 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 89 with CompoundButton

use of android.widget.CompoundButton in project BaseRecyclerViewAdapterHelper by CymChad.

the class BaseViewHolder method setOnCheckedChangeListener.

/**
     * Sets the on checked change listener of the view.
     *
     * @param viewId   The view id.
     * @param listener The checked change listener of compound button.
     * @return The BaseViewHolder for chaining.
     */
public BaseViewHolder setOnCheckedChangeListener(int viewId, CompoundButton.OnCheckedChangeListener listener) {
    CompoundButton view = getView(viewId);
    view.setOnCheckedChangeListener(listener);
    return this;
}
Also used : CompoundButton(android.widget.CompoundButton)

Example 90 with CompoundButton

use of android.widget.CompoundButton in project android_packages_apps_Torch by CyanogenMod.

the class MainActivity method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mButtonOn = (ToggleButton) findViewById(R.id.buttonOn);
    mStrobeSwitch = (Switch) findViewById(R.id.strobe_switch);
    mStrobeLabel = (TextView) findViewById(R.id.strobeTimeLabel);
    mSlider = (SeekBar) findViewById(R.id.slider);
    mBrightSwitch = (Switch) findViewById(R.id.bright_switch);
    mStrobePeriod = 100;
    mTorchOn = false;
    mWidgetProvider = TorchWidgetProvider.getInstance();
    // Preferences
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mHasBrightSetting = getResources().getBoolean(R.bool.hasHighBrightness);
    if (mHasBrightSetting) {
        mBright = mPrefs.getBoolean("bright", false);
        mBrightSwitch.setChecked(mBright);
        mBrightSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked && mPrefs.getBoolean("bright", false)) {
                    mBright = true;
                } else if (isChecked) {
                    openBrightDialog();
                } else {
                    mBright = false;
                    mPrefs.edit().putBoolean("bright", false).commit();
                }
            }
        });
    } else {
        // Fully hide the UI elements on Crespo since we can't use them
        mBrightSwitch.setVisibility(View.GONE);
        findViewById(R.id.ruler2).setVisibility(View.GONE);
    }
    // Set the state of the strobing section and hide as appropriate
    final boolean isStrobing = mPrefs.getBoolean("strobe", false);
    final LinearLayout strobeLayout = (LinearLayout) findViewById(R.id.strobeRow);
    int visibility = isStrobing ? View.VISIBLE : View.GONE;
    strobeLayout.setVisibility(visibility);
    mStrobeSwitch.setChecked(isStrobing);
    mStrobeSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            int visibility = isChecked ? View.VISIBLE : View.GONE;
            strobeLayout.setVisibility(visibility);
            mPrefs.edit().putBoolean("strobe", isChecked).commit();
        }
    });
    mButtonOn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(TorchSwitch.TOGGLE_FLASHLIGHT);
            intent.putExtra("strobe", mStrobeSwitch.isChecked());
            intent.putExtra("period", mStrobePeriod);
            intent.putExtra("bright", mBright);
            sendBroadcast(intent);
        }
    });
    // Strobe frequency slider bar handling
    setProgressBarVisibility(true);
    updateStrobePeriod(mPrefs.getInt("strobeperiod", 100));
    mSlider.setHorizontalScrollBarEnabled(true);
    mSlider.setProgress(400 - mStrobePeriod);
    mSlider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            updateStrobePeriod(Math.max(20, 401 - progress));
            Intent intent = new Intent("net.cactii.flash2.SET_STROBE");
            intent.putExtra("period", mStrobePeriod);
            sendBroadcast(intent);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    // Show the about dialog, the first time the user runs the app.
    if (!mPrefs.getBoolean("aboutSeen", false)) {
        openAboutDialog();
        mPrefs.edit().putBoolean("aboutSeen", true).commit();
    }
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) SeekBar(android.widget.SeekBar) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) OnSeekBarChangeListener(android.widget.SeekBar.OnSeekBarChangeListener) TextView(android.widget.TextView) View(android.view.View) CompoundButton(android.widget.CompoundButton) LinearLayout(android.widget.LinearLayout)

Aggregations

CompoundButton (android.widget.CompoundButton)249 View (android.view.View)129 TextView (android.widget.TextView)102 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)63 ImageView (android.widget.ImageView)50 CheckBox (android.widget.CheckBox)45 AdapterView (android.widget.AdapterView)27 Intent (android.content.Intent)26 Button (android.widget.Button)24 DialogInterface (android.content.DialogInterface)23 LayoutInflater (android.view.LayoutInflater)23 OnClickListener (android.view.View.OnClickListener)20 Switch (android.widget.Switch)18 SeekBar (android.widget.SeekBar)17 SwitchCompat (android.support.v7.widget.SwitchCompat)15 AlertDialog (android.app.AlertDialog)14 RecyclerView (android.support.v7.widget.RecyclerView)13 ArrayList (java.util.ArrayList)13 LinearLayout (android.widget.LinearLayout)12 OnClickListener (android.content.DialogInterface.OnClickListener)11