Java Code Examples for android.widget.CompoundButton#getId()

The following examples show how to use android.widget.CompoundButton#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RadioGridGroup.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    // prevents from infinite recursion
    if (mProtectFromCheckedChange) {
        return;
    }

    mProtectFromCheckedChange = true;
    if (mCheckedId != -1) {
        setCheckedStateForView(mCheckedId, false);
    }
    mProtectFromCheckedChange = false;

    int id = buttonView.getId();
    setCheckedId(id);
}
 
Example 2
Source File: SettingFragment.java    From Awesome-WanAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
    switch (compoundButton.getId()) {
        case R.id.cb_setting_night:
            mPresenter.setNightModeState(b);
            RxBus.getDefault().post(new NightModeEvent(b));
            break;
        case R.id.cb_setting_image:
            mPresenter.setNoImageState(b);
            break;
        case R.id.cb_setting_cache:
            mPresenter.setAutoCacheState(b);
            break;
        default:
            break;
    }
}
 
Example 3
Source File: WidgetConfigureActivity.java    From privacy-friendly-pedometer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor editor = sharedPref.edit();
    int value = -1;
    if(isChecked){
        switch (buttonView.getId()){
            case R.id.stepsRadioButton:
                value = WidgetReceiver.DATA_SET_STEPS;
                break;
            case R.id.distanceRadioButton:
                value = WidgetReceiver.DATA_SET_DISTANCE;
                break;
            case R.id.caloriesRadioButton:
                value = WidgetReceiver.DATA_SET_CALORIES;
                break;
        }
        editor.putInt(getString(R.string.pref_widget_data_set) + widgetId, value);
        editor.apply();
        WidgetReceiver.forceWidgetUpdate(this);
    }
}
 
Example 4
Source File: LinphoneLoginFragment.java    From Linphone4Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
	if(buttonView.getId() == R.id.use_username) {
		if(isChecked) {
			usernameLayout.setVisibility(View.VISIBLE);
			passwordLayout.setVisibility(View.VISIBLE);
			phoneNumberEdit.setVisibility(EditText.GONE);
			phoneNumberLayout.setVisibility(LinearLayout.GONE);
			messagePhoneNumber.setText(getString(R.string.assistant_linphone_login_desc));
			recoverAccount = false;
		} else {
			usernameLayout.setVisibility(View.GONE);
			passwordLayout.setVisibility(View.GONE);
			phoneNumberEdit.setVisibility(EditText.VISIBLE);
			phoneNumberLayout.setVisibility(LinearLayout.VISIBLE);
			messagePhoneNumber.setText(getString(R.string.assistant_create_account_part_1));
			recoverAccount = true;
		}
	}
}
 
Example 5
Source File: PasscodeLockCard.java    From narrate-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.settings_title:
            postDelayed(new Runnable() {
                @Override
                public void run() {
                    if ( mActivity != null ) {
                        int type = AppLockManager.getInstance().getCurrentAppLock().isPasswordLocked() ? DISABLE_PASSLOCK : ENABLE_PASSLOCK;
                        Intent i = new Intent(mActivity, PasscodeManagePasswordActivity.class);
                        i.putExtra("type", type);
                        mActivity.startActivityForResult(i, type);
                    }
                }
            }, 300);
            return;
    }
}
 
Example 6
Source File: CircleScalePopUpWindow.java    From ViewPagerLayoutManager with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.s_infinite:
            recyclerView.scrollToPosition(0);
            circleScaleLayoutManager.setInfinite(isChecked);
            break;
        case R.id.s_auto_center:
            if (isChecked) {
                centerSnapHelper.attachToRecyclerView(recyclerView);
            } else {
                centerSnapHelper.attachToRecyclerView(null);
            }
            break;
        case R.id.s_reverse:
            circleScaleLayoutManager.scrollToPosition(0);
            circleScaleLayoutManager.setReverseLayout(isChecked);
            break;
        case R.id.s_flip:
            circleScaleLayoutManager.setFlipRotate(isChecked);
            break;
    }
}
 
Example 7
Source File: MainActivity.java    From BrokenView with MIT License 6 votes vote down vote up
private void initToggleButton(){
    ToggleButton effectBtn = (ToggleButton) findViewById(R.id.toggle_effect);
    ToggleButton callbackBtn = (ToggleButton) findViewById(R.id.toggle_callback);
    final BrokenCallback callback = new MyCallBack();
    CompoundButton.OnCheckedChangeListener listener = new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isOpen) {
            switch (buttonView.getId()) {
                case R.id.toggle_effect:
                    effectEnable = isOpen;
                    break;
                case R.id.toggle_callback:
                    mBrokenView.setCallback(isOpen ? callback : null);
                    break;
            }
        }
    };
    effectBtn.setOnCheckedChangeListener(listener);
    callbackBtn.setOnCheckedChangeListener(listener);
}
 
Example 8
Source File: MapFragment.java    From MapForTour with MIT License 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.switchLBSTrace:
            if (isChecked) {
                polylineMyTrace = new PolylineOptions();
                refreshMapUI();
                mlistener.toolbarOperateCloseTrackOrOpenColor(true);
            } else {
                mlistener.toolbarOperateCloseTrackOrOpenColor(false);
            }
            break;
        case R.id.switchLocation:
            if (isChecked) {
                baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.FOLLOWING, false, null));
                baiduMap.animateMapStatus(MapStatusUpdateFactory.zoomTo(baiduMap.getMaxZoomLevel() - 2));
            } else
                baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, false, null));
            break;
    }
}
 
Example 9
Source File: VolumeDialogPreferenceFragmentX.java    From PhoneProfilesPlus with Apache License 2.0 6 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (buttonView.getId() == R.id.volumePrefDialogNoChange)
    {
        preference.noChange = (isChecked)? 1 : 0;

        valueText.setEnabled((preference.noChange == 0) /*&& (preference.sharedProfile == 0)*/);
        seekBar.setEnabled((preference.noChange == 0) /*&& (preference.sharedProfile == 0)*/);
        //if (isChecked)
        //    sharedProfileChBox.setChecked(false);
    }

    /*
    if (buttonView.getId() == R.id.volumePrefDialogSharedProfile)
    {
        preference.sharedProfile = (isChecked)? 1 : 0;

        valueText.setEnabled((preference.noChange == 0) && (preference.sharedProfile == 0));
        seekBar.setEnabled((preference.noChange == 0) && (preference.sharedProfile == 0));
        if (isChecked)
            noChangeChBox.setChecked(false);
    }
    */

    preference.callChangeListener(preference.getSValue());
}
 
Example 10
Source File: BasicManagedProfileFragment.java    From android-BasicManagedProfile with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
    switch (compoundButton.getId()) {
        case R.id.toggle_calculator: {
            setAppEnabled(PACKAGE_NAME_CALCULATOR, checked);
            mCalculatorEnabled = checked;
            break;
        }
        case R.id.toggle_chrome: {
            setAppEnabled(PACKAGE_NAME_CHROME, checked);
            mChromeEnabled = checked;
            break;
        }
    }
}
 
Example 11
Source File: PreferenceCard.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if ( buttonView.getId() == R.id.settings_title ) {
        if (isChecked) {
            animateOpen();
        } else {
            animateClosed();
        }
    }
}
 
Example 12
Source File: ZPositionAnimationDemoFragment.java    From android-materialshadowninepatch with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.checkbox_force_use_compat_mode:
            setForceCompatMode(isChecked);
            break;
    }
}
 
Example 13
Source File: WriteMessageFragment.java    From PlayTogether with Apache License 2.0 5 votes vote down vote up
/**
 * 选择图片以及emoji表情实际上是两个checkbox,在这个方法处理之
 */
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
	switch (buttonView.getId())
	{
		case R.id.cbSelectEmoji:
			if (isChecked)//打开emoji选框,同时隐藏键盘
			{
				showEmojiSelectBox();
			} else//隐藏emoji选框
			{
				hideEmojiSelectBox(false);
			}
			break;
		case R.id.cbSelectPic:
			if (isChecked)//打开图片选框,同时隐藏键盘
			{
				showPicSelectBox();

			} else//隐藏图片选框
			{
				hidePicSelectBox(false);
			}
			break;
	}
}
 
Example 14
Source File: CircleProgressBarActivity.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.cpb_sh_progress_mode:
            mProgress.setProgressMode(isChecked ?
                    CircleProgressBar.ProgressMode.LOADING :
                    CircleProgressBar.ProgressMode.PROGRESS);
            break;
        case R.id.cpb_sh_loading_repeat_mode:
            mProgress.setLoadingRepeatMode(isChecked ? ValueAnimator.REVERSE :
                    ValueAnimator.RESTART);
            break;
        case R.id.cpb_sh_loading_draw_other:
            mProgress.setLoadingDrawOther(isChecked);
            break;
        case R.id.cpb_sh_gradient:
            if (isChecked)
                mProgress.setGradientColors(0xff33b5e5, 0xff99cc00, 0xffffbb33,
                        0xffff4444, 0xff33b5e5);
            else
                mProgress.setGradientColors(0xffff4444);
            break;
        case R.id.cpb_sh_progress_value:
            mProgress.setShowSpecialDialValue(isChecked);
            break;
        case R.id.cpb_sh_special_dial_value:
            mProgress.setShowSpecialDialValue(isChecked);
            break;
    }
}
 
Example 15
Source File: AuthenticationView.java    From Atomic with GNU General Public License v3.0 5 votes vote down vote up
/**
 * On checkbox changed
 */
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  switch ( buttonView.getId() ) {
    case R.id.nickserv_checkbox:
      findViewById(R.id.nickservHolder).setVisibility(isChecked? View.VISIBLE:View.GONE);
      nickservPasswordLabel.setEnabled(isChecked);
      nickservPasswordEditText.setEnabled(isChecked);

      if( !isChecked ) {
        nickservPasswordEditText.setText("");
      }

      break;

    case R.id.sasl_checkbox:
      findViewById(R.id.saslHolder).setVisibility(isChecked? View.VISIBLE:View.GONE);
      saslUsernameLabel.setEnabled(isChecked);
      saslUsernameEditText.setEnabled(isChecked);
      saslPasswordLabel.setEnabled(isChecked);
      saslPasswordEditText.setEnabled(isChecked);

      if( !isChecked ) {
        saslUsernameEditText.setText("");
        saslPasswordEditText.setText("");
      }

      break;
  }
}
 
Example 16
Source File: BasicManagedProfileFragment.java    From enterprise-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
    switch (compoundButton.getId()) {
        case R.id.toggle_calculator: {
            setAppEnabled(PACKAGE_NAME_CALCULATOR, checked);
            mCalculatorEnabled = checked;
            break;
        }
        case R.id.toggle_chrome: {
            setAppEnabled(PACKAGE_NAME_CHROME, checked);
            mChromeEnabled = checked;
            break;
        }
    }
}
 
Example 17
Source File: ZPositionDemoFragment.java    From android-materialshadowninepatch with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.checkbox_force_use_compat_mode:
            setForceCompatMode(isChecked);
            break;
    }
}
 
Example 18
Source File: GeoFence_Polygon_Activity.java    From Android_Location_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
	switch (buttonView.getId()) {
		case R.id.cb_alertIn :
			if (isChecked) {
				activatesAction |= GeoFenceClient.GEOFENCE_IN;
			} else {
				activatesAction = activatesAction
						& (GeoFenceClient.GEOFENCE_OUT
								| GeoFenceClient.GEOFENCE_STAYED);
			}
			break;
		case R.id.cb_alertOut :
			if (isChecked) {
				activatesAction |= GeoFenceClient.GEOFENCE_OUT;
			} else {
				activatesAction = activatesAction
						& (GeoFenceClient.GEOFENCE_IN
								| GeoFenceClient.GEOFENCE_STAYED);
			}
			break;
		case R.id.cb_alertStated :
			if (isChecked) {
				activatesAction |= GeoFenceClient.GEOFENCE_STAYED;
			} else {
				activatesAction = activatesAction
						& (GeoFenceClient.GEOFENCE_IN
								| GeoFenceClient.GEOFENCE_OUT);
			}
			break;
		default :
			break;
	}
	if (null != fenceClient) {
		fenceClient.setActivateAction(activatesAction);
	}
}
 
Example 19
Source File: StatsAppWidgetConfigure.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
    switch (buttonView.getId()) {
        case R.id.shortname:
            setAdapter();
            return;
        default:
            return;
    }
}
 
Example 20
Source File: MapActivity.java    From WechatHook-Dusan with Apache License 2.0 4 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (buttonView.getId()==R.id.btn_auto_change) {
        mIsAuto = isChecked;
    }
}