Here are the examples of the java api android.widget.CompoundButton taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
402 Examples
19
Source : MineFragment.java
with GNU General Public License v3.0
from z-chu
with GNU General Public License v3.0
from z-chu
/**
* Created by Chu on 2017/5/28.
*/
public clreplaced MineFragment extends BaseFragment implements View.OnClickListener {
private CompoundButton swNightMode;
public static MineFragment newInstance() {
MineFragment fragment = new MineFragment();
return fragment;
}
@Override
public int getLayoutId() {
return R.layout.fragment_mine;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
swNightMode = view.findViewById(R.id.sw_night_mode);
swNightMode.setChecked(AppConfig.isNightMode());
swNightMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
AppCompatActivity activity = (AppCompatActivity) getActivity();
if (!b) {
activity.getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
AppConfig.setNightMode(false);
swNightMode.setChecked(false);
} else {
activity.getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
AppConfig.setNightMode(true);
swNightMode.setChecked(true);
}
activity.recreate();
}
});
bindOnClickLister(view, this, R.id.tv_action_login, R.id.mine_app_setting, R.id.mine_app_night_mode, R.id.mine_app_share, R.id.mine_app_good_reputation, R.id.mine_app_feedback, R.id.mine_app_about);
}
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
if (hidden) {
MobclickAgent.onPageEnd(getClreplaced().getPackage().getName() + ".MineFragment");
} else {
MobclickAgent.onPageStart(getClreplaced().getPackage().getName() + ".MineFragment");
}
}
@Override
public void onClick(View view) {
switch(view.getId()) {
case R.id.tv_action_login:
ToastUtil.showToast(getString(R.string.developing));
break;
case R.id.mine_app_setting:
ToastUtil.showToast(getString(R.string.developing));
break;
case R.id.mine_app_night_mode:
AppCompatActivity activity = (AppCompatActivity) getActivity();
if (AppConfig.isNightMode()) {
activity.getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
AppConfig.setNightMode(false);
swNightMode.setChecked(false);
} else {
activity.getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
AppConfig.setNightMode(true);
swNightMode.setChecked(true);
}
activity.recreate();
break;
case R.id.mine_app_share:
Shares.share(getContext(), R.string.share_text);
break;
case R.id.mine_app_good_reputation:
AppRouter.showAppMarket(getContext());
break;
case R.id.mine_app_feedback:
ToastUtil.showToast(getString(R.string.developing));
break;
case R.id.mine_app_about:
AppRouter.showAboutActivity(getContext());
break;
}
}
}
19
Source : MainActivity.java
with Apache License 2.0
from Yee-chen
with Apache License 2.0
from Yee-chen
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch(buttonView.getId()) {
case R.id.swt:
if (!isChecked) {
mFacetector.stopDetector();
} else {
mFacetector.startDetector();
}
break;
}
}
19
Source : ConstraintLayoutGroupFragment.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch(buttonView.getId()) {
case R.id.sb_group:
group.setVisibility(isChecked ? View.VISIBLE : View.GONE);
break;
case R.id.sb_group2:
group2.setVisibility(isChecked ? View.VISIBLE : View.GONE);
break;
default:
break;
}
}
19
Source : CityPickerFragment.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch(buttonView.getId()) {
case R.id.cb_hot:
if (isChecked) {
mHotCities = new ArrayList<>();
mHotCities.add(new HotCity("北京", "北京", "101010100"));
mHotCities.add(new HotCity("上海", "上海", "101020100"));
mHotCities.add(new HotCity("广州", "广东", "101280101"));
mHotCities.add(new HotCity("深圳", "广东", "101280601"));
mHotCities.add(new HotCity("杭州", "浙江", "101210101"));
} else {
mHotCities = null;
}
break;
case R.id.cb_anim:
mAnim = isChecked ? R.style.CustomAnim : R.style.CityPickerAnimation;
break;
case R.id.cb_enable_anim:
mEnableAnimation = isChecked;
break;
default:
break;
}
}
19
Source : SwitchButtonFragment.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
XToastUtils.toast("isChecked:" + isChecked);
}
19
Source : SkinCompatCompoundButtonHelper.java
with MIT License
from ximsfei
with MIT License
from ximsfei
/**
* Created by ximsfei on 17-1-14.
*/
public clreplaced SkinCompatCompoundButtonHelper extends SkinCompatHelper {
private final CompoundButton mView;
private int mButtonResourceId = INVALID_ID;
private int mButtonTintResId = INVALID_ID;
public SkinCompatCompoundButtonHelper(CompoundButton view) {
mView = view;
}
void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
TypedArray a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.CompoundButton, defStyleAttr, INVALID_ID);
try {
if (a.hasValue(R.styleable.CompoundButton_android_button)) {
mButtonResourceId = a.getResourceId(R.styleable.CompoundButton_android_button, INVALID_ID);
}
if (a.hasValue(R.styleable.CompoundButton_buttonTint)) {
mButtonTintResId = a.getResourceId(R.styleable.CompoundButton_buttonTint, INVALID_ID);
}
} finally {
a.recycle();
}
applySkin();
}
public void setButtonDrawable(int resId) {
mButtonResourceId = resId;
applySkin();
}
@Override
public void applySkin() {
mButtonResourceId = SkinCompatHelper.checkResourceId(mButtonResourceId);
if (mButtonResourceId != INVALID_ID) {
mView.setButtonDrawable(SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mButtonResourceId));
}
mButtonTintResId = SkinCompatHelper.checkResourceId(mButtonTintResId);
if (mButtonTintResId != INVALID_ID) {
CompoundButtonCompat.setButtonTintList(mView, SkinCompatResources.getColorStateList(mView.getContext(), mButtonTintResId));
}
}
}
19
Source : SkinCompatCompoundButtonHelper.java
with MIT License
from ximsfei
with MIT License
from ximsfei
/**
* Created by ximsfei on 17-1-14.
*/
public clreplaced SkinCompatCompoundButtonHelper extends SkinCompatHelper {
private final CompoundButton mView;
private int mButtonResourceId = INVALID_ID;
private int mButtonTintResId = INVALID_ID;
public SkinCompatCompoundButtonHelper(CompoundButton view) {
mView = view;
}
void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
TypedArray a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.CompoundButton, defStyleAttr, INVALID_ID);
try {
if (a.hasValue(R.styleable.CompoundButton_android_button)) {
mButtonResourceId = a.getResourceId(R.styleable.CompoundButton_android_button, INVALID_ID);
}
// if (resourceId != 0) {
// mView.setButtonDrawable(
// AppCompatResources.getDrawable(mView.getContext(), resourceId));
// }
// }
if (a.hasValue(R.styleable.CompoundButton_buttonTint)) {
mButtonTintResId = a.getResourceId(R.styleable.CompoundButton_buttonTint, INVALID_ID);
}
// if (a.hasValue(R.styleable.CompoundButton_buttonTintMode)) {
// CompoundButtonCompat.setButtonTintMode(mView,
// DrawableUtils.parseTintMode(
// a.getInt(R.styleable.CompoundButton_buttonTintMode, -1),
// null));
// }
} finally {
a.recycle();
}
applySkin();
}
public void setButtonDrawable(int resId) {
mButtonResourceId = resId;
applySkin();
}
@Override
public void applySkin() {
mButtonResourceId = SkinCompatHelper.checkResourceId(mButtonResourceId);
if (mButtonResourceId != INVALID_ID) {
mView.setButtonDrawable(SkinCompatResources.getDrawableCompat(mView.getContext(), mButtonResourceId));
}
mButtonTintResId = SkinCompatHelper.checkResourceId(mButtonTintResId);
if (mButtonTintResId != INVALID_ID) {
CompoundButtonCompat.setButtonTintList(mView, SkinCompatResources.getColorStateList(mView.getContext(), mButtonTintResId));
}
}
}
19
Source : SkinCompatCompoundButtonHelper.java
with MIT License
from ximsfei
with MIT License
from ximsfei
/**
* Created by ximsfei on 17-1-14.
*/
public clreplaced SkinCompatCompoundButtonHelper extends SkinCompatHelper {
private final CompoundButton mView;
private int mButtonResourceId = INVALID_ID;
public SkinCompatCompoundButtonHelper(CompoundButton view) {
mView = view;
}
void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
TypedArray a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.SkinCompatCompoundButton, defStyleAttr, INVALID_ID);
try {
if (a.hasValue(R.styleable.SkinCompatCompoundButton_android_button)) {
mButtonResourceId = a.getResourceId(R.styleable.SkinCompatCompoundButton_android_button, INVALID_ID);
}
} finally {
a.recycle();
}
applySkin();
}
public void setButtonDrawable(int resId) {
mButtonResourceId = resId;
applySkin();
}
@Override
public void applySkin() {
mButtonResourceId = SkinCompatHelper.checkResourceId(mButtonResourceId);
if (mButtonResourceId != INVALID_ID) {
mView.setButtonDrawable(SkinCompatResources.getInstance().getDrawable(mButtonResourceId));
}
}
}
19
Source : SettingSwitchItem.java
with Apache License 2.0
from xfhy
with Apache License 2.0
from xfhy
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
switchStatus = true;
} else {
switchStatus = false;
}
}
19
Source : SkinCompatCompoundButtonHelper.java
with MIT License
from wutongke
with MIT License
from wutongke
/**
* Created by ximsfei on 17-1-14.
*/
public clreplaced SkinCompatCompoundButtonHelper extends SkinCompatHelper {
private final CompoundButton mView;
private int mButtonResourceId = INVALID_ID;
public SkinCompatCompoundButtonHelper(CompoundButton view) {
mView = view;
}
void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
TypedArray a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.CompoundButton, defStyleAttr, INVALID_ID);
try {
if (a.hasValue(R.styleable.CompoundButton_android_button)) {
mButtonResourceId = a.getResourceId(R.styleable.CompoundButton_android_button, INVALID_ID);
}
// if (resourceId != 0) {
// mView.setButtonDrawable(
// AppCompatResources.getDrawable(mView.getContext(), resourceId));
// }
// }
// if (a.hasValue(R.styleable.CompoundButton_buttonTint)) {
// CompoundButtonCompat.setButtonTintList(mView,
// a.getColorStateList(R.styleable.CompoundButton_buttonTint));
// }
// if (a.hasValue(R.styleable.CompoundButton_buttonTintMode)) {
// CompoundButtonCompat.setButtonTintMode(mView,
// DrawableUtils.parseTintMode(
// a.getInt(R.styleable.CompoundButton_buttonTintMode, -1),
// null));
// }
} finally {
a.recycle();
}
applySkin();
}
public void setButtonDrawable(int resId) {
mButtonResourceId = resId;
applySkin();
}
@Override
public void applySkin() {
mButtonResourceId = SkinCompatHelper.checkResourceId(mButtonResourceId);
if (mButtonResourceId != INVALID_ID) {
mView.setButtonDrawable(SkinCompatResources.getInstance().getDrawable(mButtonResourceId));
}
}
}
19
Source : IncreasingRingPreference.java
with Apache License 2.0
from WrBug
with Apache License 2.0
from WrBug
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateVolumeNoticeVisibility(mMinVolumeSeekBar.getProgress());
updateEnabledStates();
}
19
Source : HierarchyFragment.java
with Apache License 2.0
from whataa
with Apache License 2.0
from whataa
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isExpand) {
getAdapter().performClick(0);
} else {
expandAllViews();
}
isExpand = !isExpand;
}
19
Source : Tutorial1Fragment.java
with GNU General Public License v3.0
from Welthungerhilfe
with GNU General Public License v3.0
from Welthungerhilfe
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (fragmentTutorial1Binding.guide1.isChecked() && fragmentTutorial1Binding.guide2.isChecked()) {
fragmentTutorial1Binding.btnNext.setBackgroundResource(R.drawable.button_green_circular);
} else {
fragmentTutorial1Binding.btnNext.setBackgroundResource(R.drawable.button_green_light_circular);
}
}
19
Source : MultiCurrencyListAdapter.java
with MIT License
from webkul
with MIT License
from webkul
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setChecked((Integer) buttonView.getTag(), isChecked);
}
19
Source : WrapperOnCheckedChangeListener.java
with Apache License 2.0
from wangzhzh
with Apache License 2.0
from wangzhzh
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
// 调用原有的 OnClickListener
try {
if (source != null) {
source.onCheckedChanged(compoundButton, b);
}
} catch (Exception e) {
e.printStackTrace();
}
// 插入埋点代码
SensorsDataPrivate.trackViewOnClick(compoundButton);
}
19
Source : SkinCompatCompoundButtonHelper.java
with MIT License
from usernameyangyan
with MIT License
from usernameyangyan
public clreplaced SkinCompatCompoundButtonHelper extends SkinCompatHelper {
private final CompoundButton mView;
private int mButtonResourceId = INVALID_ID;
private int mButtonTintResId = INVALID_ID;
public SkinCompatCompoundButtonHelper(CompoundButton view) {
mView = view;
}
void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
TypedArray a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.CompoundButton, defStyleAttr, INVALID_ID);
try {
if (a.hasValue(R.styleable.CompoundButton_android_button)) {
mButtonResourceId = a.getResourceId(R.styleable.CompoundButton_android_button, INVALID_ID);
}
if (a.hasValue(R.styleable.CompoundButton_buttonTint)) {
mButtonTintResId = a.getResourceId(R.styleable.CompoundButton_buttonTint, INVALID_ID);
}
} finally {
a.recycle();
}
applySkin();
}
public void setButtonDrawable(int resId) {
mButtonResourceId = resId;
applySkin();
}
@Override
public void applySkin() {
mButtonResourceId = SkinCompatHelper.checkResourceId(mButtonResourceId);
if (mButtonResourceId != INVALID_ID) {
mView.setButtonDrawable(SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mButtonResourceId));
}
mButtonTintResId = SkinCompatHelper.checkResourceId(mButtonTintResId);
if (mButtonTintResId != INVALID_ID) {
CompoundButtonCompat.setButtonTintList(mView, SkinCompatResources.getColorStateList(mView.getContext(), mButtonTintResId));
}
}
}
19
Source : SettingsFragment.java
with Apache License 2.0
from ukevgen
with Apache License 2.0
from ukevgen
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
presenter.setNotificationsState(isChecked);
}
19
Source : ConfigDialog.java
with Apache License 2.0
from ucloud
with Apache License 2.0
from ucloud
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
config.setAutoDetect(isChecked);
}
19
Source : CommonDeviceDebugPresenter.java
with MIT License
from TuyaInc
with MIT License
from TuyaInc
public void onCheckedChanged(CompoundButton compoundButton, boolean value) {
sendCommand((String) compoundButton.getTag(R.id.schemaId), value);
}
19
Source : VigenereCipherActivity.java
with GNU General Public License v3.0
from tranleduy2000
with GNU General Public License v3.0
from tranleduy2000
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
processData();
}
19
Source : EqualizerFragment.java
with GNU General Public License v3.0
from timusus
with GNU General Public License v3.0
from timusus
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mediaManager.closeEqualizerSessions(!isChecked, mediaManager.getAudioSessionId());
mediaManager.openEqualizerSession(isChecked, mediaManager.getAudioSessionId());
// set parameter and state
prefs.edit().putBoolean("audiofx.global.enable", isChecked).apply();
mediaManager.updateEqualizer();
}
19
Source : TDOnWidgetsChangeAspect.java
with Apache License 2.0
from ThinkingDataAnalytics
with Apache License 2.0
from ThinkingDataAnalytics
@After("execution(* android.widget.CompoundButton.OnCheckedChangeListener.onCheckedChanged(android.widget.CompoundButton, boolean)) " + "&& args(buttonView, isChecked) ")
public void onCompoundButtonCheckedChanged(final JoinPoint joinPoint, CompoundButton buttonView, boolean isChecked) throws Throwable {
AopUtils.trackViewClickEvent(joinPoint, buttonView);
}
19
Source : jni_string.java
with MIT License
from stytooldex
with MIT License
from stytooldex
public clreplaced jni_string extends AppCompatActivity implements OnCheckedChangeListener, OnCancelListener, OnClickListener {
CompoundButton mCompoundButton;
android.support.v7.widget.Toolbar toolbar;
@TargetApi(21)
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked && compoundButton == mCompoundButton && getResources().getBoolean(R.bool.use_accessibility_service) && WatchingAccessibilityService.getInstance() == null) {
new Builder(this).setMessage(R.string.dialog_enable_accessibility_msg).setPositiveButton(R.string.dialog_enable_accessibility_positive_btn, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction("android.settings.ACCESSIBILITY_SETTINGS");
startActivity(intent);
}
}).setNegativeButton(R.string.dialog_enable_accessibility_Nagetive_btn, this).setOnCancelListener(this).create().show();
DefaultSharedPreferences.save(this, isChecked);
} else if (compoundButton == mCompoundButton) {
DefaultSharedPreferences.save(this, isChecked);
if (isChecked) {
ViewWindow.showView(this, getPackageName() + "\n" + getClreplaced().getName());
} else {
ViewWindow.removeView();
}
}
}
public void ok(View view) {
Intent intent = new Intent(jni_string.this, FxService.clreplaced);
startService(intent);
finish();
}
public void no(View view) {
Intent intent = new Intent(jni_string.this, FxService.clreplaced);
stopService(intent);
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.jni_main);
StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
ViewWindow.showView(this, "");
mCompoundButton = (CompoundButton) findViewById(R.id.sw_window);
mCompoundButton.setOnCheckedChangeListener(this);
if (getResources().getBoolean(R.bool.use_watching_service)) {
startService(new Intent(this, WatchingService.clreplaced));
}
}
protected void onPause() {
super.onPause();
if (!DefaultSharedPreferences.read(this)) {
return;
}
if (!getResources().getBoolean(R.bool.use_accessibility_service) || WatchingAccessibilityService.getInstance() != null) {
NotificationActionReceiver.showNotification(this, false);
}
}
protected void onResume() {
super.onResume();
status();
NotificationActionReceiver.initNotification(this);
}
@Override
public void onCancel(DialogInterface dialog) {
status();
}
@Override
public void onClick(DialogInterface dialog, int which) {
status();
}
private void status() {
mCompoundButton.setChecked(DefaultSharedPreferences.read(this));
if (getResources().getBoolean(R.bool.use_accessibility_service) && WatchingAccessibilityService.getInstance() == null) {
mCompoundButton.setChecked(false);
}
}
}
19
Source : jni_string.java
with MIT License
from stytooldex
with MIT License
from stytooldex
@TargetApi(21)
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked && compoundButton == mCompoundButton && getResources().getBoolean(R.bool.use_accessibility_service) && WatchingAccessibilityService.getInstance() == null) {
new Builder(this).setMessage(R.string.dialog_enable_accessibility_msg).setPositiveButton(R.string.dialog_enable_accessibility_positive_btn, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction("android.settings.ACCESSIBILITY_SETTINGS");
startActivity(intent);
}
}).setNegativeButton(R.string.dialog_enable_accessibility_Nagetive_btn, this).setOnCancelListener(this).create().show();
DefaultSharedPreferences.save(this, isChecked);
} else if (compoundButton == mCompoundButton) {
DefaultSharedPreferences.save(this, isChecked);
if (isChecked) {
ViewWindow.showView(this, getPackageName() + "\n" + getClreplaced().getName());
} else {
ViewWindow.removeView();
}
}
}
19
Source : SwitchBar.java
with Apache License 2.0
from starscryer
with Apache License 2.0
from starscryer
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
propagateChecked(isChecked);
}
19
Source : ThemeFragment.java
with Apache License 2.0
from SoyaLeaf
with Apache License 2.0
from SoyaLeaf
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (RADIO_BUTTON[mCurrentTheme] != buttonView.getId() && isChecked) {
for (int i = 0; i < RADIO_BUTTON.length; i++) {
if (buttonView.getId() == RADIO_BUTTON[i]) {
final int finalI = i;
new Thread() {
@Override
public void run() {
Message obtain = Message.obtain();
obtain.what = UPDATE;
obtain.arg1 = finalI;
mHandler.sendMessage(obtain);
}
}.start();
break;
}
}
}
}
19
Source : SwitchPropertyEditor.java
with GNU General Public License v2.0
from sovworks
with GNU General Public License v2.0
from sovworks
public abstract clreplaced SwitchPropertyEditor extends PropertyEditorBase {
public SwitchPropertyEditor(Host host, int replacedleResId, int descResId) {
super(host, R.layout.settings_switch_editor, replacedleResId, descResId);
}
@Override
public View createView(ViewGroup parent) {
View view = super.createView(parent);
_switchButton = view.findViewById(android.R.id.button1);
_switchButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (!_loadingValue) {
if (!onChecked(isChecked))
buttonView.setChecked(!isChecked);
}
});
return view;
}
@Override
public void load() {
_loadingValue = true;
try {
_switchButton.setChecked(loadValue());
} finally {
_loadingValue = false;
}
}
@Override
public void load(Bundle b) {
if (_switchButton == null)
return;
if (isInstantSave())
load();
else {
_loadingValue = true;
try {
_switchButton.setChecked(b.getBoolean(getBundleKey()));
} finally {
_loadingValue = false;
}
}
}
@Override
public void save() {
saveValue(_switchButton.isChecked());
}
@Override
public void save(Bundle b) {
if (!isInstantSave() && _switchButton != null)
b.putBoolean(getBundleKey(), _switchButton.isChecked());
}
@Override
public void onClick() {
_switchButton.toggle();
}
protected boolean getCurrentValue() {
return _switchButton.isChecked();
}
protected CompoundButton _switchButton;
private boolean _loadingValue;
protected abstract boolean loadValue();
protected abstract void saveValue(boolean value);
protected boolean onChecked(boolean isChecked) {
if (_host.getPropertiesView().isInstantSave())
save();
return true;
}
}
19
Source : PlayerDebugActivity.java
with GNU General Public License v3.0
from shadow578
with GNU General Public License v3.0
from shadow578
/**
* Common Switch state change listener for switches in VideoTest activity
*
* @param compoundButton the switch that changed
* @param isChecked is the switch not checked (=enabled)?
*/
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
switch(compoundButton.getId()) {
case R.id.vtest_tgl_open_direct:
{
// open direct switch changed, enable/disable open by share toggle
swOpenShare.setEnabled(!isChecked);
break;
}
case R.id.vtest_tgl_add_replacedle_extra:
{
// insert replacedles switch changed, enable/disable non standard replacedle toggle
swUseNonStandardreplacedle.setEnabled(isChecked);
break;
}
default:
break;
}
}
19
Source : MainActivity.java
with Apache License 2.0
from rubensousa
with Apache License 2.0
from rubensousa
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
mCardShadowTransformer.enableScaling(b);
mFragmentCardShadowTransformer.enableScaling(b);
}
19
Source : CallSettingsPagerView.java
with MIT License
from rongcloud
with MIT License
from rongcloud
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
switch(compoundButton.getId()) {
case R.id.s_call_settings_audio_params:
{
isAudioChecked = b;
if (listener != null) {
listener.onAudioSwitch(b);
}
break;
}
default:
{
break;
}
}
}
19
Source : Proxmark3ConsoleActivity.java
with GNU General Public License v3.0
from RfidResearchGroup
with GNU General Public License v3.0
from RfidResearchGroup
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// don't need process!!!
}
19
Source : ToggleGroup.java
with MIT License
from rcketscientist
with MIT License
from rcketscientist
void drawDividersVertical(Canvas canvas) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final CompoundButton child = (CompoundButton) getChildAt(i);
if (hasDividerBeforeChildAt(i)) {
final LinearLayoutCompat.LayoutParams lp = (LinearLayoutCompat.LayoutParams) child.getLayoutParams();
final int top = child.getTop() - lp.topMargin - mDividerHeight;
drawHorizontalDivider(canvas, top);
}
}
}
19
Source : ToggleGroup.java
with MIT License
from rcketscientist
with MIT License
from rcketscientist
CompoundButton getVisibleViewBeforeChildAt(int index) {
index--;
while (index >= 0) {
final CompoundButton previous = (CompoundButton) getChildAt(index);
if (previous.getVisibility() != GONE)
return previous;
index--;
}
return null;
}
19
Source : ToggleGroup.java
with MIT License
from rcketscientist
with MIT License
from rcketscientist
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (child instanceof CompoundButton) {
final CompoundButton button = (CompoundButton) child;
if (button.isChecked()) {
mProtectFromCheckedChange = true;
int currentCheck = getExclusiveCheckedId();
if (mExclusive && currentCheck != View.NO_ID) {
setCheckedStateForView(currentCheck, false);
}
mProtectFromCheckedChange = false;
addCheckedId(button.getId());
}
}
super.addView(child, index, params);
}
19
Source : ToggleGroup.java
with MIT License
from rcketscientist
with MIT License
from rcketscientist
/**
* Determines where to position dividers between children. Note: this is an 'illegal' override
* of a hidden method.
*
* @param childIndex Index of child to check for preceding divider
* @return true if there should be a divider before the child at childIndex
*/
protected boolean hasDividerBeforeChildAt(int childIndex) {
final CompoundButton child = (CompoundButton) getChildAt(childIndex);
if (child == null)
return false;
if (child.getVisibility() == GONE)
return false;
final CompoundButton previous = getVisibleViewBeforeChildAt(childIndex);
if (previous == null)
return false;
// If both are checked, add a divider
return child.isChecked() && previous.isChecked();
}
19
Source : ToggleGroup.java
with MIT License
from rcketscientist
with MIT License
from rcketscientist
void drawDividersHorizontal(Canvas canvas) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final CompoundButton child = (CompoundButton) getChildAt(i);
if (hasDividerBeforeChildAt(i)) {
final LinearLayoutCompat.LayoutParams lp = (LinearLayoutCompat.LayoutParams) child.getLayoutParams();
final int left = child.getLeft() - lp.leftMargin - mDividerWidth;
drawVerticalDivider(canvas, left);
}
}
}
19
Source : QTalkUserLoginActivity.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
void autoLoginHandler(CompoundButton cbx, boolean isChecked) {
if (isChecked) {
qtuer_remember_me_cbx.setChecked(isChecked);
qtuer_remember_me_cbx.setEnabled(false);
} else {
qtuer_remember_me_cbx.setEnabled(true);
}
}
19
Source : LoginActivity.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
void autoLoginHandler(CompoundButton cbx, boolean isChecked) {
if (isChecked) {
remember_me_cbx.setChecked(isChecked);
remember_me_cbx.setEnabled(false);
} else {
remember_me_cbx.setEnabled(true);
}
}
19
Source : DynamicCheckPreference.java
with Apache License 2.0
from pranavpandey
with Apache License 2.0
from pranavpandey
/**
* A {@link DynamicSimplePreference} to provide the functionality of a
* {@link android.preference.SwitchPreference}.
*/
public clreplaced DynamicCheckPreference extends DynamicSimplePreference {
/**
* Default value for the checked state.
*/
public static final boolean DEFAULT_CHECK_STATE = false;
/**
* {@code true} if this preference is checked.
*/
private boolean mChecked;
/**
* Optional summary for the unchecked state.
*/
private CharSequence mSummaryUnchecked;
/**
* Checked change listener to get the callback when compound button state is changed.
*/
private CompoundButton.OnCheckedChangeListener mOnCheckedChangeListener;
/**
* Compound button to show the checked state.
*/
private CompoundButton mCompoundButton;
public DynamicCheckPreference(@NonNull Context context) {
super(context);
}
public DynamicCheckPreference(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public DynamicCheckPreference(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onLoadAttributes(@Nullable AttributeSet attrs) {
super.onLoadAttributes(attrs);
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.DynamicCheckPreference);
try {
mChecked = a.getBoolean(R.styleable.DynamicCheckPreference_ads_checked, DEFAULT_CHECK_STATE);
mSummaryUnchecked = a.getString(R.styleable.DynamicCheckPreference_ads_unchecked);
} finally {
a.recycle();
}
}
@Override
protected void onInflate() {
super.onInflate();
mCompoundButton = LayoutInflater.from(getContext()).inflate(R.layout.ads_preference_check, this, false).findViewById(R.id.ads_preference_check_switch);
setViewFrame(mCompoundButton, true);
setOnPreferenceClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setChecked(!isChecked());
}
}, false);
mCompoundButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (getOnCheckedChangeListener() != null) {
getOnCheckedChangeListener().onCheckedChanged(compoundButton, isChecked());
}
}
});
}
@Override
protected void onUpdate() {
super.onUpdate();
mChecked = DynamicPreferences.getInstance().load(getPreferenceKey(), isChecked());
if (getCompoundButton() != null) {
if (!isChecked() && getSummaryUnchecked() != null) {
setTextView(getSummaryView(), getSummaryUnchecked());
}
getCompoundButton().post(mUpdateRunnable);
}
}
/**
* Runnable to post the update.
*/
private final Runnable mUpdateRunnable = new Runnable() {
@Override
public void run() {
if (getCompoundButton() != null) {
getCompoundButton().setChecked(isChecked());
}
}
};
@Override
protected void onEnabled(boolean enabled) {
super.onEnabled(enabled);
Dynamic.setEnabled(getCompoundButton(), enabled);
}
@Override
public void setColor() {
super.setColor();
Dynamic.setContrastWithColorTypeOrColor(getCompoundButton(), getContrastWithColorType(), getContrastWithColor());
Dynamic.setBackgroundAwareSafe(getCompoundButton(), getBackgroundAware());
}
/**
* Returns whether this preference is checked.
*
* @return {@code true} if this preference is checked.
*/
public boolean isChecked() {
return mChecked;
}
/**
* Set the state of the switch to be checked or unchecked.
*
* @param checked {@code true} if this preference is checked.
*/
public void setChecked(boolean checked) {
this.mChecked = checked;
DynamicPreferences.getInstance().save(getPreferenceKey(), checked);
}
/**
* Get the optional summary for the unchecked state.
*
* @return The optional summary for the unchecked state.
*/
@Nullable
public CharSequence getSummaryUnchecked() {
return mSummaryUnchecked;
}
/**
* Set the optional summary for the unchecked state.
*
* @param summaryUnchecked The unchecked summary to be set.
*/
public void setSummaryUnchecked(@Nullable String summaryUnchecked) {
this.mSummaryUnchecked = summaryUnchecked;
update();
}
/**
* Get the compound button used by this preference.
*
* @return The compound button used by this preference.
*/
@Nullable
public CompoundButton getCompoundButton() {
return mCompoundButton;
}
/**
* Returns the checked change listener.
*
* @return The checked change listener to get the callback if switch state is changed.
*/
@Nullable
public CompoundButton.OnCheckedChangeListener getOnCheckedChangeListener() {
return mOnCheckedChangeListener;
}
/**
* Set the checked change listener to get the callback if switch state is changed.
*
* @param onCheckedChangeListener The listener to be set.
*/
public void setOnCheckedChangeListener(@Nullable CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
this.mOnCheckedChangeListener = onCheckedChangeListener;
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
super.onSharedPreferenceChanged(sharedPreferences, key);
if (DynamicPreferences.isNullKey(key)) {
return;
}
if (key.equals(super.getPreferenceKey())) {
update();
}
}
}
19
Source : StockAdapter.java
with Apache License 2.0
from oubowu
with Apache License 2.0
from oubowu
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int pos = (Integer) buttonView.getTag();
mData.get(pos).getData().check = isChecked;
}
19
Source : BooleanSettingsObject.java
with Apache License 2.0
from or-dvir
with Apache License 2.0
from or-dvir
/**
* @param compoundButton changes the text of the given {@link CompoundButton}
* according if it's "on" or "off"
*/
public void setTextAccordingToState(CompoundButton compoundButton) {
if (compoundButton.isChecked()) {
compoundButton.setText(onText);
} else if (compoundButton.isChecked() == false) {
compoundButton.setText(offText);
}
}
19
Source : ExpandableActivity.java
with MIT License
from Omega-R
with MIT License
from Omega-R
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
switch(buttonView.getId()) {
case R.id.radiobutton_fade:
mRecyclerView.sereplacedemAnimator(FADE_ANIMATOR);
break;
case R.id.radiobutton_dropdown:
mRecyclerView.sereplacedemAnimator(DROPDOWN_ANIMATOR);
break;
case R.id.radiobutton_single:
mRecyclerView.setExpandMode(OmegaExpandableRecyclerView.EXPAND_MODE_SINGLE);
break;
case R.id.radiobutton_multiple:
mRecyclerView.setExpandMode(OmegaExpandableRecyclerView.EXPAND_MODE_MULTIPLE);
break;
}
}
}
19
Source : CheckBoxBindingAdapterUtils.java
with GNU General Public License v3.0
from NightscoutFoundation
with GNU General Public License v3.0
from NightscoutFoundation
@BindingAdapter(value = { "onCheckedChanged", "checkedAttrChanged" }, requireAll = false)
public static void setListeners(CompoundButton view, final OnCheckedChangeListener listener, final InverseBindingListener attrChange) {
if (attrChange == null) {
view.setOnCheckedChangeListener(listener);
} else {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (listener != null) {
listener.onCheckedChanged(buttonView, isChecked);
}
attrChange.onChange();
}
});
}
}
19
Source : CheckBoxBindingAdapterUtils.java
with GNU General Public License v3.0
from NightscoutFoundation
with GNU General Public License v3.0
from NightscoutFoundation
@BindingAdapter(value = { "checked" })
public static void setChecked(CompoundButton view, Boolean checked) {
if (checked == null)
checked = false;
setChecked(view, (boolean) checked);
}
19
Source : ToggleButtonGroup.java
with Apache License 2.0
from nex3z
with Apache License 2.0
from nex3z
private void setStateTracker(CompoundButton view) {
if (mCompoundButtonStateTracker == null) {
mCompoundButtonStateTracker = new CompoundButtonCheckedStateTracker();
}
view.setOnCheckedChangeListener(mCompoundButtonStateTracker);
}
19
Source : ToggleButtonGroup.java
with Apache License 2.0
from nex3z
with Apache License 2.0
from nex3z
private void clearStateTracker(CompoundButton view) {
view.setOnCheckedChangeListener(null);
}
19
Source : SettingsFragment.java
with Apache License 2.0
from mzlogin
with Apache License 2.0
from mzlogin
@OnCheckedChanged(R.id.comments_order_desc)
public void onCommentsOrderDescChanged(CompoundButton button, boolean value) {
PrefsUtil.putBoolean(App.getInstance(), ConstantUtil.KEY_COMMENTS_ORDER_DESC, value);
}
19
Source : PackageSettingLayout.java
with GNU General Public License v3.0
from mthli
with GNU General Public License v3.0
from mthli
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView == mMountSwitch && mListener != null) {
mListener.onMountSwitchChanged(isChecked);
}
}
19
Source : HorizontalProgressFragment.java
with Apache License 2.0
from Moosphan
with Apache License 2.0
from Moosphan
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch(buttonView.getId()) {
case R.id.hsc_isTracked:
if (isChecked) {
horizontalProgressView.setTrackEnabled(true);
} else {
horizontalProgressView.setTrackEnabled(false);
}
break;
case R.id.hsc_text_visibility:
if (isChecked) {
horizontalProgressView.setProgressTextVisibility(true);
} else {
horizontalProgressView.setProgressTextVisibility(false);
}
break;
}
}
19
Source : MainActivity.java
with Apache License 2.0
from mapleqin
with Apache License 2.0
from mapleqin
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
adjustCornerRadius(mCornerRadiusSeekBar.getProgress());
}
See More Examples