List of usage examples for android.widget Switch isChecked
@ViewDebug.ExportedProperty @Override public boolean isChecked()
From source file:nl.hnogames.domoticz.Welcome.WelcomePage3.java
private void writePreferenceValues() { mServerUtil.getActiveServer()/*from w ww. j a va 2s.c om*/ .setRemoteServerUsername(remote_username_input.getInputWidgetText().toString()); mServerUtil.getActiveServer() .setRemoteServerPassword(remote_password_input.getInputWidgetText().toString()); mServerUtil.getActiveServer().setRemoteServerUrl(remote_server_input.getInputWidgetText().toString()); mServerUtil.getActiveServer().setRemoteServerPort(remote_port_input.getInputWidgetText().toString()); mServerUtil.getActiveServer() .setRemoteServerDirectory(remote_directory_input.getInputWidgetText().toString()); mServerUtil.getActiveServer().setRemoteServerSecure(getSpinnerDomoticzRemoteSecureBoolean()); if (callingInstance == WELCOME_WIZARD) mSharedPrefs.setStartupScreenIndex(startScreenSelectedPosition); Switch useSameAddress = (Switch) v.findViewById(R.id.localServer_switch); if (!useSameAddress.isChecked()) { mServerUtil.getActiveServer().setLocalSameAddressAsRemote(); mServerUtil.getActiveServer().setIsLocalServerAddressDifferent(false); } else { mServerUtil.getActiveServer() .setLocalServerUsername(local_username_input.getInputWidgetText().toString()); mServerUtil.getActiveServer() .setLocalServerPassword(local_password_input.getInputWidgetText().toString()); mServerUtil.getActiveServer().setLocalServerUrl(local_server_input.getInputWidgetText().toString()); mServerUtil.getActiveServer().setLocalServerPort(local_port_input.getInputWidgetText().toString()); mServerUtil.getActiveServer() .setLocalServerDirectory(local_directory_input.getInputWidgetText().toString()); mServerUtil.getActiveServer().setLocalServerSecure(getSpinnerDomoticzLocalSecureBoolean()); mServerUtil.getActiveServer().setIsLocalServerAddressDifferent(true); } mServerUtil.getActiveServer().setLocalServerSsid(local_wifi_spinner.getSelectedStrings()); mServerUtil.saveDomoticzServers(true); }
From source file:org.dharmaseed.android.NavigationActivity.java
/** * Called when the "Downloaded only" switch in the nav drawer is pressed * @param view//w w w .ja va2 s .co m */ public void downloadOnlySwitchClicked(View view) { Switch downloadSwitch = (Switch) view; downloadedOnly = downloadSwitch.isChecked(); updateDisplayedData(); }
From source file:com.danielme.android.webviewdemo.WebViewDemoActivity.java
/** * call back from UI/*from www .j ava 2 s .c om*/ * * @param view */ public void freeQuotaClick(View view) { Switch s = (Switch) view; if (running) { if (!s.isChecked()) { stopUsingFreeQuota(); } if (s.isChecked()) { startUsingFreeQuota(); } } }
From source file:com.synox.android.ui.fragment.ShareFileFragment.java
/** * Updates in the UI the section about public share with the information in the current * public share bound to mFile, if any/*from ww w .ja va2 s. co m*/ */ private void updatePublicShareSection() { if (mPublicShare != null && ShareType.PUBLIC_LINK.equals(mPublicShare.getShareType())) { /// public share bound -> expand section Switch shareViaLinkSwitch = getShareViaLinkSwitch(); if (!shareViaLinkSwitch.isChecked()) { // set null listener before setChecked() to prevent infinite loop of calls shareViaLinkSwitch.setOnCheckedChangeListener(null); shareViaLinkSwitch.setChecked(true); shareViaLinkSwitch.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener); } getExpirationDateSection().setVisibility(View.VISIBLE); getPasswordSection().setVisibility(View.VISIBLE); // GetLink button AppCompatButton getLinkButton = getGetLinkButton(); getLinkButton.setVisibility(View.VISIBLE); getLinkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //GetLink from the server and show ShareLinkToDialog ((FileActivity) getActivity()).getFileOperationsHelper().getFileWithLink(mFile); } }); /// update state of expiration date switch and message depending on expiration date Switch expirationDateSwitch = getExpirationDateSwitch(); // set null listener before setChecked() to prevent infinite loop of calls expirationDateSwitch.setOnCheckedChangeListener(null); long expirationDate = mPublicShare.getExpirationDate(); if (expirationDate > 0) { if (!expirationDateSwitch.isChecked()) { expirationDateSwitch.toggle(); } String formattedDate = SimpleDateFormat.getDateInstance().format(new Date(expirationDate)); getExpirationDateValue().setText(formattedDate); } else { if (expirationDateSwitch.isChecked()) { expirationDateSwitch.toggle(); } getExpirationDateValue().setText(R.string.empty); } // recover listener expirationDateSwitch.setOnCheckedChangeListener(mOnExpirationDateInteractionListener); /// update state of password switch and message depending on password protection Switch passwordSwitch = getPasswordSwitch(); // set null listener before setChecked() to prevent infinite loop of calls passwordSwitch.setOnCheckedChangeListener(null); if (mPublicShare.isPasswordProtected()) { if (!passwordSwitch.isChecked()) { passwordSwitch.toggle(); } getPasswordValue().setVisibility(View.VISIBLE); } else { if (passwordSwitch.isChecked()) { passwordSwitch.toggle(); } getPasswordValue().setVisibility(View.INVISIBLE); } // recover listener passwordSwitch.setOnCheckedChangeListener(mOnPasswordInteractionListener); } else { /// no public share -> collapse section Switch shareViaLinkSwitch = getShareViaLinkSwitch(); if (shareViaLinkSwitch.isChecked()) { shareViaLinkSwitch.setOnCheckedChangeListener(null); getShareViaLinkSwitch().setChecked(false); shareViaLinkSwitch.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener); } getExpirationDateSection().setVisibility(View.GONE); getPasswordSection().setVisibility(View.GONE); getGetLinkButton().setVisibility(View.GONE); } }
From source file:com.pimp.companionforband.activities.main.MainActivity.java
void setSwitch(Switch s, TextView textView, String string) { if (!s.isChecked()) { editor.putBoolean(string, false); editor.apply();//from w w w. j av a2 s. c o m textView.setVisibility(View.GONE); } else { editor.putBoolean(string, true); editor.apply(); textView.setVisibility(View.VISIBLE); } }
From source file:com.adamas.client.android.MainActivity.java
public void refreshMenu() { if (_menuItemStartStop != null) { final Switch mySwitch = (Switch) _menuItemStartStop.getActionView() .findViewById(R.id.switchForStartStopConnector); _checked = Boolean.valueOf(mySwitch.isChecked()); }/*from w w w.j a va2 s .c o m*/ invalidateOptionsMenu(); // openOptionsMenu(); // closeOptionsMenu(); }
From source file:info.corne.performancetool.MainActivity.java
/** * If the overclock switch is clicked this function * will change the textview containing some information. * @param view//from w ww . j a v a 2s. co m */ public void onOverclockSwitchClick(View view) { Switch ocSwitch = (Switch) view; TextView overclockInfo = (TextView) findViewById(R.id.overclockInfo); if (ocSwitch.isChecked()) overclockInfo.setText(getResources().getString(R.string.allow_overclock_on)); else overclockInfo.setText(getResources().getString(R.string.allow_overclock_off)); }
From source file:com.adamas.client.android.MainActivity.java
@Override public boolean handleMessage(Message msg) { if (_menuItemStartStop == null) { return true; }//from w ww .ja v a2s .c om if (msg.what == MSG_UPDATE_VPN_STATE) { String state = (String) msg.obj; int code = msg.arg1; if (code == VpnStatus.CONNECTED || code == VpnStatus.NOT_CONNECTED) { _menuItemStartStop.getActionView().findViewById(R.id.switchForStartStopConnector) .setVisibility(View.VISIBLE); _menuItemStartStop.getActionView().findViewById(R.id.progressBarConnecting) .setVisibility(View.GONE); Switch myswitch = (Switch) _menuItemStartStop.getActionView() .findViewById(R.id.switchForStartStopConnector); if (code == VpnStatus.CONNECTED && !myswitch.isChecked()) { _runProcessConnectDisconnectKey = false; myswitch.setChecked(true); } else if (code == VpnStatus.NOT_CONNECTED && myswitch.isChecked()) { _runProcessConnectDisconnectKey = false; myswitch.setChecked(false); } if (code == VpnStatus.CONNECTED) { toast(getResources().getString(R.string.vpn_is_connected), ToastType.info); if (connectClicked) { connectClicked = false; showHomeUrl(); } } else { toast(getResources().getString(R.string.vpn_is_not_connected), ToastType.error); } if (_connectorfragment != null) { _connectorfragment.vpnAdaptorNotifyDataSetChanged(); } } else if (code == VpnStatus.CONNECTING || code == VpnStatus.DISCONNECTING) { _menuItemStartStop.getActionView().findViewById(R.id.switchForStartStopConnector) .setVisibility(View.GONE); _menuItemStartStop.getActionView().findViewById(R.id.progressBarConnecting) .setVisibility(View.VISIBLE); } else { //TODO impossible to get here _menuItemStartStop.getActionView().findViewById(R.id.switchForStartStopConnector) .setVisibility(View.VISIBLE); _menuItemStartStop.getActionView().findViewById(R.id.progressBarConnecting) .setVisibility(View.GONE); toast(getResources().getString(R.string.vpn_is_not_connected), ToastType.error); if (_connectorfragment != null) { _connectorfragment.vpnAdaptorNotifyDataSetChanged(); } } } changeHomeImage(); return true; }
From source file:info.corne.performancetool.MainActivity.java
/** * If the lp overclock switch is clicked this function * will change the textview containing some information. * @param view//from w w w .j a v a2 s. co m */ public void onLpOverclockSwitchClick(View view) { Switch lpOcSwitch = (Switch) view; TextView lpOverclockInfo = (TextView) findViewById(R.id.lpOverclockInfo); if (lpOcSwitch.isChecked()) lpOverclockInfo.setText(getResources().getString(R.string.allow_lpoverclock_on)); else lpOverclockInfo.setText(getResources().getString(R.string.allow_lpoverclock_off)); }
From source file:com.example.accountkitsample.MainActivity.java
private AccountKitConfiguration.AccountKitConfigurationBuilder createAccountKitConfiguration( final LoginType loginType) { AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder( loginType, getResponseType()); final Switch titleTypeSwitch = (Switch) findViewById(R.id.title_type_switch); final Switch stateParamSwitch = (Switch) findViewById(R.id.state_param_switch); final Switch facebookNotificationsSwitch = (Switch) findViewById(R.id.facebook_notification_switch); final Switch useManualWhiteListBlacklist = (Switch) findViewById(R.id.whitelist_blacklist_switch); final Switch readPhoneStateSwitch = (Switch) findViewById(R.id.read_phone_state_switch); final Switch receiveSMS = (Switch) findViewById(R.id.receive_sms_switch); if (titleTypeSwitch != null && titleTypeSwitch.isChecked()) { configurationBuilder.setTitleType(AccountKitActivity.TitleType.APP_NAME); }/* www . ja v a 2 s. com*/ if (advancedUISwitch != null && advancedUISwitch.isChecked()) { if (isReverbThemeSelected()) { if (switchLoginTypeReceiver == null) { switchLoginTypeReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { final String loginTypeString = intent.getStringExtra(ReverbUIManager.LOGIN_TYPE_EXTRA); if (loginTypeString == null) { return; } final LoginType loginType = LoginType.valueOf(loginTypeString); if (loginType == null) { return; } onLogin(loginType); } }; LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver( switchLoginTypeReceiver, new IntentFilter(ReverbUIManager.SWITCH_LOGIN_TYPE_EVENT)); } configurationBuilder.setAdvancedUIManager( new ReverbUIManager(confirmButton, entryButton, loginType, textPosition, selectedThemeId)); } else { configurationBuilder.setAdvancedUIManager( new AccountKitSampleAdvancedUIManager(confirmButton, entryButton, textPosition, loginType)); } } if (stateParamSwitch != null && stateParamSwitch.isChecked()) { initialStateParam = UUID.randomUUID().toString(); configurationBuilder.setInitialAuthState(initialStateParam); } if (facebookNotificationsSwitch != null && !facebookNotificationsSwitch.isChecked()) { configurationBuilder.setFacebookNotificationsEnabled(false); } if (selectedThemeId > 0) { configurationBuilder.setTheme(selectedThemeId); } if (useManualWhiteListBlacklist != null && useManualWhiteListBlacklist.isChecked()) { final String[] blackList = getResources().getStringArray(R.array.blacklistedSmsCountryCodes); final String[] whiteList = getResources().getStringArray(R.array.whitelistedSmsCountryCodes); configurationBuilder.setSMSBlacklist(blackList); configurationBuilder.setSMSWhitelist(whiteList); } if (readPhoneStateSwitch != null && !(readPhoneStateSwitch.isChecked())) { configurationBuilder.setReadPhoneStateEnabled(false); } if (receiveSMS != null && !receiveSMS.isChecked()) { configurationBuilder.setReceiveSMS(false); } return configurationBuilder; }