Example usage for android.widget CompoundButton isChecked

List of usage examples for android.widget CompoundButton isChecked

Introduction

In this page you can find the example usage for android.widget CompoundButton isChecked.

Prototype

@ViewDebug.ExportedProperty
    @Override
    public boolean isChecked() 

Source Link

Usage

From source file:it.cosenonjaviste.twowaydatabinding.DataBindingConverters.java

@BindingAdapter({ "app:binding" })
public static void bindCompoundButton(CompoundButton view, final ObservableBoolean observableBoolean) {
    if (observableBoolean != null) {
        if (view.getTag(R.id.bound_observable) != observableBoolean) {
            view.setTag(R.id.bound_observable, observableBoolean);
            view.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override/*from   w w  w  .  j  a  va 2 s  .com*/
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    observableBoolean.set(isChecked);
                }
            });
        }
        boolean newValue = observableBoolean.get();
        if (view.isChecked() != newValue) {
            view.setChecked(newValue);
        }
    }
}

From source file:com.todoroo.astrid.ui.ImportanceControlSet.java

public Integer getImportance() {
    for (CompoundButton b : buttons) {
        if (b.isChecked()) {
            return (Integer) b.getTag();
        }//from  www. ja va 2  s  .  c  o  m
    }
    return null;
}

From source file:net.semantic_error.turritype.sample.TypeActivity.java

@OnCheckedChanged({ R.id.strategy_node, R.id.strategy_natural, R.id.strategy_linear })
void pauseChange(CompoundButton checkBox) {
    if (!checkBox.isChecked())
        return;//from   w  w  w. j  a  v a  2s  . c o m
    switch (checkBox.getId()) {
    case R.id.strategy_node:
        pauseStrategy = new NoPauseStrategy();
        break;
    case R.id.strategy_linear:
        pauseStrategy = new LinearPauseStrategy(500, 1200);
        break;
    case R.id.strategy_natural:
        pauseStrategy = new NaturalPauseStrategy();
        break;
    default:
        speed = TurriType.NORMAL_SPEED;
        throw new IllegalStateException("Unsupported interpolator");
    }
    updateAnimator();
}

From source file:net.semantic_error.turritype.sample.TypeActivity.java

@OnCheckedChanged({ R.id.interpolator_one, R.id.interpolator_multiple })
void interpolatorChange(CompoundButton checkBox) {
    if (!checkBox.isChecked())
        return;/*from  www  .  j a v a2  s  .  c  o m*/
    switch (checkBox.getId()) {
    case R.id.interpolator_one:
        interpolatorList = null;
        interpolator = new FastOutSlowInInterpolator();
        break;
    case R.id.interpolator_multiple:
        interpolator = null;
        interpolatorList = getDefaultInterpolatorList();
        break;

    default:
        speed = TurriType.NORMAL_SPEED;
        throw new IllegalStateException("Unsupported interpolator");
    }
    updateAnimator();

}

From source file:net.semantic_error.turritype.sample.TypeActivity.java

@OnCheckedChanged(R.id.is_naturally)
void naturallyChange(CompoundButton isNaturally) {
    this.isNaturally = isNaturally.isChecked();
    detailSettings.setVisibility(this.isNaturally ? View.GONE : View.VISIBLE);
    updateAnimator();//from  w w  w  .  j av  a 2s .  c o m
}

From source file:net.semantic_error.turritype.sample.TypeActivity.java

@OnCheckedChanged({ R.id.speed_very_fast, R.id.speed_fast, R.id.speed_very_slow, R.id.speed_slow,
        R.id.speed_normal })/*from   w w  w.j a  v  a 2s. c  om*/
void speedChange(CompoundButton checkBox) {
    if (!checkBox.isChecked())
        return;

    switch (checkBox.getId()) {
    case R.id.speed_very_slow:
        speed = TurriType.VERY_SLOW_SPEED;
        break;
    case R.id.speed_slow:
        speed = TurriType.SLOW_SPEED;
        break;
    case R.id.speed_normal:
        speed = TurriType.NORMAL_SPEED;
        break;
    case R.id.speed_fast:
        speed = TurriType.FAST_SPEED;
        break;
    case R.id.speed_very_fast:
        speed = TurriType.VERY_FAST_SPEED;
        break;

    default:
        throw new IllegalStateException("Unsupported speed");
    }
    updateAnimator();
}

From source file:org.kaaproject.kaa.examples.gpiocontol.adapters.GPIOAdapter.java

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
    final GpioStatus gpioStatus = mGpioStatuses.get(position);

    holder.switcher.setChecked(gpioStatus.getStatus());
    holder.gpioId.setText(String.valueOf(gpioStatus.getId()) /*+ " [" + gpioStatus.getType() + "]"*/);

    final int teaColor = ContextCompat.getColor(mContext, R.color.tea_color);
    holder.gpioId.setTextColor(holder.switcher.isChecked() ? teaColor : Color.RED);

    holder.switcher.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override/* ww  w.ja  v  a2 s . co  m*/
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            //Skips system recycler invoking
            if (!buttonView.isPressed())
                return;

            gpioStatus.setStatus(isChecked);

            holder.gpioId.setTextColor(buttonView.isChecked() ? teaColor : Color.RED);
            mKaaManager.sendGpioToggleRequest(new GpioToggleRequest(gpioStatus), mDevice.getKaaEndpointId());
        }
    });
}

From source file:com.simplechatclient.android.ProfileAddFragment.java

private void add_profile_switch_registered() {
    CompoundButton compoundButtonRegistered = (CompoundButton) view
            .findViewById(R.id.add_profile_switch_registered);
    EditText editTextNewPassword = (EditText) view.findViewById(R.id.editTextNewPassword);

    if (compoundButtonRegistered.isChecked()) {
        editTextNewPassword.setVisibility(View.VISIBLE);
    } else {/*w ww .  java 2  s  . co  m*/
        editTextNewPassword.setVisibility(View.GONE);
    }
}

From source file:com.anxpp.blog.fragment.SandboxFragment.java

private void saveBooleanPrefState(Bundle outState, int prefValue) {
    final CompoundButton viewValue = (CompoundButton) viewRoot.findViewById(prefValue);
    outState.putBoolean(String.valueOf(prefValue), viewValue.isChecked());
}

From source file:com.h6ah4i.android.example.openslmediaplayer.app.contents.HQVisualizerFragment.java

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    ViewCompat.setAlpha(buttonView, buttonView.isChecked() ? 0.5f : 1.0f);

    if (mDuringSetupViews)
        return;// w  w  w  .java2s  . c om

    switch (buttonView.getId()) {
    case R.id.toggle_button_visualizer_enable_waveform:
        postAppEvent(HQVisualizerReqEvents.SET_WAVEFORM_ENABLED, (isChecked ? 1 : 0), 0);
        break;
    case R.id.toggle_button_visualizer_enable_fft:
        postAppEvent(HQVisualizerReqEvents.SET_FFT_ENABLED, (isChecked ? 1 : 0), 0);
        break;
    }
}