android.widget.CompoundButton Java Examples
The following examples show how to use
android.widget.CompoundButton.
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: PushSettingFragment.java From umeng_community_android with MIT License | 7 votes |
@Override protected void initWidgets() { int switchButtonResId = ResFinder.getId( "umeng_common_switch_button"); mSwitchButton = (SwitchButton) mRootView .findViewById(switchButtonResId); mSwitchButton.setChecked(mSDKConfig.isPushEnable(getActivity())); mSwitchButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // 保存配置 CommConfig.getConfig().setSDKPushable(getActivity(), isChecked); } }); }
Example #2
Source File: TokensChipAdapter.java From SSForms with GNU General Public License v3.0 | 6 votes |
@Override public View createSearchView(Context context, boolean is_checked, final int pos) { View view = View.inflate(context, R.layout.tokens_search,null); CheckBox cbCheck = view.findViewById(R.id.cbCheck); cbCheck.setText((String)search_data.get(pos).getValue()); cbCheck.setChecked(is_checked); cbCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if(b){ tokens.add(search_data.get(pos)); //refresh(); }else{ tokens.remove(search_data.get(pos)); //refresh(); } } }); return view; }
Example #3
Source File: MainActivity.java From views-widgets-samples with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRadioGroup = (RadioGroup) findViewById(R.id.radioGroup); mPredictiveCB = (CheckBox) findViewById(R.id.predictiveCB); mCustomCB = (CheckBox) findViewById(R.id.customCB); mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview); mRecyclerView.setLayoutManager(new MyLinearLayoutManager(this)); mRecyclerView.setAdapter(new RVAdapter()); mCustomCB.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mRecyclerView.setItemAnimator(isChecked ? mChangeAnimator : mDefaultItemAnimator); } }); }
Example #4
Source File: BasePreViewActivity.java From TestChat with Apache License 2.0 | 6 votes |
@Override public void initView() { back = (ImageView) findViewById(R.id.iv_picture_top_bar_back); description = (TextView) findViewById(R.id.tv_picture_top_bar_description); finish = (Button) findViewById(R.id.btn_picture_top_bar_finish); delete = (ImageView) findViewById(R.id.iv_picture_top_bar_delete); topBar = (RelativeLayout) findViewById(R.id.picture_top_bar); bottomView = (RelativeLayout) findViewById(R.id.rl_base_preview_bottom); origin = (CheckBox) findViewById(R.id.cb_base_preview_origin); select = (CheckBox) findViewById(R.id.cb_base_preview_select); display = (PreviewViewPager) findViewById(R.id.vp_base_preview_display); back.setOnClickListener(this); delete.setOnClickListener(this); select.setOnClickListener(this); finish.setOnClickListener(this); origin.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { origin.setText(getString(R.string.origin_size, previewList.get(currentPosition).getSize())); } else { origin.setText(getString(R.string.origin_text)); } } }); }
Example #5
Source File: GosCheckDeviceWorkWiFiActivity.java From GOpenSource_AppKit_Android_AS with MIT License | 6 votes |
private void ininEvent() { btnNext.setOnClickListener(this); imgWiFiList.setOnClickListener(this); cbLaws.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { String psw = etPsw.getText().toString(); if (isChecked) { etPsw.setInputType(0x90); } else { etPsw.setInputType(0x81); } etPsw.setSelection(psw.length()); } }); cbLaws.setChecked(true); }
Example #6
Source File: StatisticActivity.java From Rumble with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings_statistic); setTitle(R.string.settings_statistic); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setDisplayShowHomeEnabled(false); CheckBox checkBox = (CheckBox)findViewById(R.id.stat_check_box); checkBox.setChecked(RumblePreferences.UserOkWithSharingAnonymousData(this)); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { RumblePreferences.setUserPreferenceWithSharingData(StatisticActivity.this, isChecked); } }); }
Example #7
Source File: MainActivity.java From ForceDoze with GNU General Public License v3.0 | 6 votes |
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b) { editor = settings.edit(); editor.putBoolean("serviceEnabled", true); editor.apply(); serviceEnabled = true; textViewStatus.setText(R.string.service_active); if (!Utils.isMyServiceRunning(ForceDozeService.class, MainActivity.this)) { Log.i(TAG, "Enabling ForceDoze"); startService(new Intent(MainActivity.this, ForceDozeService.class)); } showForceDozeActiveDialog(); } else { editor = settings.edit(); editor.putBoolean("serviceEnabled", false); editor.apply(); serviceEnabled = false; textViewStatus.setText(R.string.service_inactive); if (Utils.isMyServiceRunning(ForceDozeService.class, MainActivity.this)) { Log.i(TAG, "Disabling ForceDoze"); stopService(new Intent(MainActivity.this, ForceDozeService.class)); } } if (Utils.isDeviceRunningOnN()) { TileService.requestListeningState(this, new ComponentName(this, ForceDozeTileService.class.getName())); } }
Example #8
Source File: ImagePagerActivity.java From ImagePicker with Apache License 2.0 | 6 votes |
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (ImageDataModel.getInstance().getResultNum() == mOptions.getMaxNum()) { showShortToast(getString(R.string.warning_imagepicker_max_num, String.valueOf(mOptions.getMaxNum()))); mCkSelected.setOnCheckedChangeListener(null);//取消监听,以免冲突 mCkSelected.setChecked(false); mCkSelected.setOnCheckedChangeListener(mCkChangeListener); } else { ImageDataModel.getInstance().addDataToResult(mDataList.get(mCurPosition)); onSelectNumChanged(); } } else { ImageDataModel.getInstance().delDataFromResult(mDataList.get(mCurPosition)); onSelectNumChanged(); } }
Example #9
Source File: VideoRecorderFragment.java From VideoRecorder with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mSurfaceView = view.findViewById(R.id.SurfaceView); mBtnRecord = view.findViewById(R.id.cbRecord); mTvFps = view.findViewById(R.id.tvFps); mBtnRecord.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (mRecorder != null) { if (mRecorder.isRecordEnable()) { mRecorder.stopRecord(); } else { mRecorder.startRecord(); } } } }); mSurfaceView.getHolder().addCallback(this); }
Example #10
Source File: AdultRowViewHolder.java From aptoide-client with GNU General Public License v2.0 | 6 votes |
@Override public void populateView(Displayable displayable) { // final AdultRowViewHolder holder = (AdultRowViewHolder) viewHolder; adultSwitch.setOnCheckedChangeListener(null); adultSwitch.setChecked(PreferenceManager.getDefaultSharedPreferences(Aptoide.getContext()).getBoolean(Constants.MATURE_CHECK_BOX, false)); adultSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { new AdultDialog().show(fragmentManager, "adultDialog"); } else { BusProvider.getInstance().post(new OttoEvents.MatureEvent(false)); } } }); }
Example #11
Source File: EditShareFragment.java From Cirrus_depricated with GNU General Public License v2.0 | 6 votes |
/** * Sync value of "can edit" {@link Switch} according to a change in one of its subordinate checkboxes. * * If all the subordinates are disabled, "can edit" has to be disabled. * * If any subordinate is enabled, "can edit" has to be enabled. * * @param subordinateCheckBoxView Subordinate {@link CheckBox} that was changed. * @param isChecked 'true' iif subordinateCheckBoxView was checked. */ private void syncCanEditSwitch(View subordinateCheckBoxView, boolean isChecked) { CompoundButton canEditCompound = (CompoundButton) getView().findViewById(R.id.canEditSwitch); if (isChecked) { if (!canEditCompound.isChecked()) { toggleDisablingListener(canEditCompound); } } else { boolean allDisabled = true; for (int i=0; allDisabled && i<sSubordinateCheckBoxIds.length; i++) { allDisabled &= sSubordinateCheckBoxIds[i] == subordinateCheckBoxView.getId() || !((CheckBox) getView().findViewById(sSubordinateCheckBoxIds[i])).isChecked() ; } if (canEditCompound.isChecked() && allDisabled) { toggleDisablingListener(canEditCompound); for (int i=0; i<sSubordinateCheckBoxIds.length; i++) { getView().findViewById(sSubordinateCheckBoxIds[i]).setVisibility(View.GONE); } } } }
Example #12
Source File: SampleActivity.java From scalpel with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sample_activity); ButterKnife.inject(this); pagerView.setAdapter(new SamplePagerAdapter(this)); Switch enabledSwitch = new Switch(this); enabledSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (first) { first = false; Toast.makeText(SampleActivity.this, R.string.first_run, LENGTH_LONG).show(); } scalpelView.setLayerInteractionEnabled(isChecked); invalidateOptionsMenu(); } }); ActionBar actionBar = getActionBar(); actionBar.setCustomView(enabledSwitch); actionBar.setDisplayOptions(DISPLAY_SHOW_TITLE | DISPLAY_SHOW_CUSTOM); }
Example #13
Source File: ConfigurationActivity.java From Noyze with Apache License 2.0 | 6 votes |
@Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent(); bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false); bar.setTitle(getTitle()); bar.inflateMenu(R.menu.toggle_switch); final MenuItem toggle = bar.getMenu().findItem(R.id.action_switch); if (null != toggle) { switchView = (CompoundButton) toggle.getActionView().findViewById(R.id.switch_view); if (null != switchView) { switchView.setChecked(VolumeAccessibilityService.isEnabled(this)); switchView.setOnCheckedChangeListener(this); } } if (isTaskRoot()) bar.setNavigationIcon(null); root.addView(bar, 0); bar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); }
Example #14
Source File: CheckGroup.java From FuAgoraDemoDroid with MIT License | 6 votes |
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // prevents from infinite recursion if (mProtectFromCheckedChange) { return; } int id = buttonView.getId(); mProtectFromCheckedChange = true; if (mCheckedId != View.NO_ID && mCheckedId != id) { setCheckedStateForView(mCheckedId, false); } mProtectFromCheckedChange = false; setCheckedId(isChecked ? id : View.NO_ID); }
Example #15
Source File: WXBottomBar.java From YImagePicker with Apache License 2.0 | 6 votes |
@Override protected void initView(View view) { mDirButton = view.findViewById(R.id.mDirButton); mPreview = view.findViewById(R.id.mPreview); mCheckBox = view.findViewById(R.id.mCheckBox); setCheckBoxDrawable(R.mipmap.picker_wechat_unselect, R.mipmap.picker_wechat_select); setBottomBarColor(Color.parseColor("#303030")); mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ImagePicker.isOriginalImage = isChecked; } }); previewText = getContext().getString(R.string.picker_str_bottom_preview); mPreview.setText(previewText); mCheckBox.setText(getContext().getString(R.string.picker_str_bottom_original)); }
Example #16
Source File: NestedRadioGroupManager.java From NestedRadioButton with Apache License 2.0 | 6 votes |
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // prevents from infinite recursion if (protectFromCheckedChange) { return; } int id = buttonView.getId(); protectFromCheckedChange = true; if (checkedId != -1 && checkedId != id) { setCheckedStateForView(checkedId, false); } protectFromCheckedChange = false; setCheckedId(id); }
Example #17
Source File: RadioButtonGroupHelper.java From AndroidProject with Apache License 2.0 | 6 votes |
/** * {@link CompoundButton.OnCheckedChangeListener} */ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked && !mTag) { mTag = true; for (CompoundButton view : mViewSet) { if (view != buttonView && view.isChecked()) { // 这个 API 会触发监听事件 view.setChecked(false); } } if (mListener != null) { mListener.onCheckedChanged((RadioButton) buttonView, buttonView.getId()); } mTag = false; } }
Example #18
Source File: SettingsMenu.java From ViewInspector with Apache License 2.0 | 6 votes |
public SettingsMenu(final Context context) { super(context); ViewInspector.runtimeComponentMap.get(context).inject(this); inflate(context, R.layout.view_inspector_settings_menu, this); Switch logViewEventsSwitch = (Switch) findViewById(R.id.log_view_events_switch); logViewEventsSwitch.setChecked(logViewEvents.get()); logViewEventsSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { logViewEvents.set(isChecked); } }); View viewFilter = findViewById(R.id.view_filter); viewFilter.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new SetViewFilterDialog( new ContextThemeWrapper(context, BaseDialog.getDialogTheme(context))).show(); } }); }
Example #19
Source File: ViewUtil.java From sa-sdk-android with Apache License 2.0 | 6 votes |
static boolean isTrackEvent(View view, boolean isFromUser) { if (view instanceof CheckBox) { if (!isFromUser) { return false; } } else if (view instanceof RadioButton) { if (!isFromUser) { return false; } } else if (view instanceof ToggleButton) { if (!isFromUser) { return false; } } else if (view instanceof CompoundButton) { if (!isFromUser) { return false; } } if (view instanceof RatingBar) { if (!isFromUser) { return false; } } return true; }
Example #20
Source File: SellConfirmCoinifyActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
@Override protected void init(Bundle savedInstanceState) { GuardaApp.getAppComponent().inject(this); setToolBarTitle(getString(R.string.toolbar_title_confirm_coinify)); baseAmount = getIntent().getFloatExtra(Extras.COINIFY_IN_AMOUNT, 0.0f); float amountWithCoinifyFee = 0.0f; payMethod = getIntent().getStringExtra(Extras.COINIFY_PAY_METHOD); fee.setText(String.format("%s %s" , getIntent().getStringExtra(Extras.COINIFY_EXCH_FEE), getIntent().getStringExtra(Extras.COINIFY_OUT_AMOUNT_CUR))); til_coinify_method_fee.setHint(String.format("%s Order", getIntent().getStringExtra(Extras.COINIFY_OUT_AMOUNT_CUR))); txfee.setText(String.format("%s %s", getIntent().getStringExtra(Extras.COINIFY_COINIFY_FEE), getIntent().getStringExtra(Extras.COINIFY_OUT_AMOUNT_CUR))); coinify_method_fee.setText(String.format("%s %s", getIntent().getStringExtra(Extras.COINIFY_AMOUNT_RATE), getIntent().getStringExtra(Extras.COINIFY_OUT_AMOUNT_CUR))); coinify_bank_chb_text.setText(R.string.coinify_sell_confirm); btnNext.setEnabled(false); DecimalFormat df = new DecimalFormat("#.##"); df.setRoundingMode(RoundingMode.HALF_EVEN); send.setText(String.format("%s %s", getIntent().getFloatExtra(Extras.COINIFY_IN_AMOUNT, 0.0f), getIntent().getStringExtra(Extras.COINIFY_IN_AMOUNT_CUR))); String tvapx = getIntent().getStringExtra(Extras.COINIFY_OUT_AMOUNT); received.setText(String.format("%s %s", tvapx, getIntent().getStringExtra(Extras.COINIFY_OUT_AMOUNT_CUR))); email.setText(sharedManager.getCoinifyEmail()); coinify_bank_chb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { btnNext.setEnabled(true); } else { btnNext.setEnabled(false); } } }); }
Example #21
Source File: ZPositionDemoFragment.java From android-materialshadowninepatch with Apache License 2.0 | 5 votes |
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.checkbox_force_use_compat_mode: setForceCompatMode(isChecked); break; } }
Example #22
Source File: ChampionListActivity.java From Theogony with MIT License | 5 votes |
private void initNavigationView() { mNavigationView.setNavigationItemSelectedListener(this); MenuItem dayNightMenuItem = mNavigationView.getMenu().findItem(R.id.menu_item_dayNight); View view = MenuItemCompat.getActionView(dayNightMenuItem); mSwitchCompat = ButterKnife.findById(view, R.id.switch_view); mSwitchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { setNightMode(isChecked); } }); mSwitchCompat.setChecked(ThemeUtils.isNightMode(this)); }
Example #23
Source File: MainActivityEvents.java From Multiwii-Remote with Apache License 2.0 | 5 votes |
@Override public void onCheckedChanged(CompoundButton arg0, boolean state) { // TODO Auto-generated method stub if(state == true){ mActivity.app.sensors.start(); } else{ mActivity.app.sensors.stop(); } }
Example #24
Source File: DetailActivity.java From android-intents-broadcast-receivers with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); TextView titleLabel = (TextView)findViewById(R.id.songTitleLabel); final CheckBox favoriteCheckbox = (CheckBox)findViewById(R.id.checkBox); mRootLayout = (RelativeLayout) findViewById(R.id.rootLayout); Intent intent = getIntent(); if (Intent.ACTION_SEND.equals(intent.getAction())) { handleSendIntent(intent); } else { // if (intent.getStringExtra(MainActivity.EXTRA_TITLE) != null) { // String songTitle = intent.getStringExtra(MainActivity.EXTRA_TITLE); // titleLabel.setText(songTitle); // } if (intent.getParcelableExtra(MainActivity.EXTRA_SONG) != null) { mSong = intent.getParcelableExtra(MainActivity.EXTRA_SONG); titleLabel.setText(mSong.getTitle()); favoriteCheckbox.setChecked(mSong.isFavorite()); } final int listPosition = intent.getIntExtra(MainActivity.EXTRA_LIST_POSITION, 0); favoriteCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Intent resultIntent = new Intent(); resultIntent.putExtra(MainActivity.EXTRA_FAVORITE, isChecked); resultIntent.putExtra(MainActivity.EXTRA_LIST_POSITION, listPosition); setResult(RESULT_OK, resultIntent); finish(); } }); } }
Example #25
Source File: jni_string.java From stynico with MIT License | 5 votes |
@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" + getClass().getName()); } else { ViewWindow.removeView(); } } }
Example #26
Source File: GeoFence_Round_Activity.java From Android_Location_Demo with Apache License 2.0 | 5 votes |
@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 #27
Source File: Option.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (mBroadcasting) { return; } getValue(mAppConfig)[0] = isChecked; // Clone current state cause it can be changed after. mBlacklist.saveAppConfig(mContext, mAppConfig, this); }
Example #28
Source File: MainActivity.java From android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_main, menu); // Set initial state of toggle and click behaviour. final SwitchCompat cjdnsServiceSwitch = (SwitchCompat) MenuItemCompat.getActionView(menu.findItem(R.id.switch_cjdns_service)); mSubscriptions.add(AppObservable.bindActivity(this, Cjdroute.running(this) .subscribeOn(Schedulers.io())) .subscribe(new Action1<Integer>() { @Override public void call(Integer pid) { // Change toggle check state if there is a currently running cjdroute process. cjdnsServiceSwitch.setChecked(true); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { // Do nothing. } }, new Action0() { @Override public void call() { // Configure toggle click behaviour. cjdnsServiceSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mBus.post(new ApplicationEvents.StartCjdnsService()); } else { mBus.post(new ApplicationEvents.StopCjdnsService()); } } }); } })); return super.onCreateOptionsMenu(menu); }
Example #29
Source File: MainActivity.java From no-player with Apache License 2.0 | 5 votes |
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { player.clearMaxVideoBitrate(); } else { player.setMaxVideoBitrate(MAX_VIDEO_BITRATE); } }
Example #30
Source File: ListItem.java From BatteryFu with GNU General Public License v2.0 | 5 votes |
void onClickInternal(View view) { if (CheckboxVisible) { CompoundButton cb = (CompoundButton)view.findViewById(R.id.checkbox); // this will trigger onclick cb.setChecked(!cb.isChecked()); } else { onClick(view); } }