List of usage examples for android.widget Switch setOnCheckedChangeListener
public void setOnCheckedChangeListener(@Nullable OnCheckedChangeListener listener)
From source file:mx.klozz.xperience.tweaker.fragments.VoltageControlSettings.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.voltage_settings, root, false); final ListView listView = (ListView) view.findViewById(R.id.ListView); final Switch setOnBoot = (Switch) view.findViewById(R.id.applyAtBoot); if (mVoltages.isEmpty()) { (view.findViewById(R.id.emptyList)).setVisibility(View.VISIBLE); (view.findViewById(R.id.BottomBar)).setVisibility(View.GONE); }//from w ww . jav a 2 s. c o m setOnBoot.setChecked(mPreferences.getBoolean(VOLTAGE_SOB, false)); setOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mPreferences.edit().putBoolean(VOLTAGE_SOB, isChecked).apply(); if (isChecked) { String warningMessage = getString(R.string.volt_info); new AlertDialog.Builder(context).setMessage(warningMessage) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setOnBoot.setChecked(false); } }).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create().show(); } } }); (view.findViewById(R.id.applyBtn)).setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { final StringBuilder sb = new StringBuilder(); final String vdd = Helpers.getVoltagePath(); if (vdd.equals(VDD_PATH)) { for (final Voltage volt : mVoltages) { if (!volt.getSavedMV().equals(volt.getCurrentMv())) { for (int i = 0; i < Helpers.getNumOfCPUS(); i++) { sb.append("busybox echo \"").append(volt.getFreq()).append(" ") .append(volt.getSavedMV()).append("\" > ") .append(vdd.replace("cpu0", "cpu" + i)).append(";\n"); } } } } else if (vdd.equals(VDD_TABLE)) { for (final Voltage volt : mVoltages) { if (!volt.getSavedMV().equals(volt.getCurrentMv())) { sb.append("busybox echo \"").append(volt.getFreq()).append(" ") .append(volt.getSavedMV()).append("\" > ").append(vdd).append(";\n"); } } } else { final StringBuilder b = new StringBuilder(); for (final Voltage volt : mVoltages) { b.append(volt.getSavedMV()).append(" "); } if (vdd.equals(COMMON_VDD_PATH)) { sb.append("busybox echo \"").append(b.toString()).append("\" > ").append(vdd).append(";\n"); } else { for (int i = 0; i < Helpers.getNumOfCPUS(); i++) { sb.append("busybox echo \"").append(b.toString()).append("\" > ") .append(vdd.replace("cpu0", "cpu" + i)).append(";\n"); } } } Helpers.shExec(sb, context, true); final List<Voltage> volts = getVolts(mPreferences); mVoltages.clear(); mVoltages.addAll(volts); mAdapter.notifyDataSetChanged(); } }); mAdapter.setListItems(mVoltages); listView.setAdapter(mAdapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mVoltage = mVoltages.get(position); showDialog(vmin, vstep, nvsteps); } }); return view; }
From source file:com.decad3nce.aegis.AegisActivity.java
private void addAdminListener(int toggle, boolean what, Switch who) { switch (toggle) { case R.id.alarm_toggle: if (what) { who.setChecked(true);/*from w w w. j ava 2 s.co m*/ } break; case R.id.lock_toggle: case R.id.wipe_toggle: case R.id.locate_toggle: if (mDevicePolicyManager.getActiveAdmins() != null) { if (what && mDevicePolicyManager.isAdminActive(DEVICE_ADMIN_COMPONENT)) { who.setChecked(true); } } break; } if (who != null) { who.setOnCheckedChangeListener(deviceAdminPreferencesOnChangeListener); } }
From source file:io.oceanos.shaderbox.dialog.PropertiesDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); final Shader shader = (Shader) getArguments().getSerializable("shader"); View view = inflater.inflate(R.layout.dialog_properties, null); final EditText nameView = (EditText) view.findViewById(R.id.name); Switch vrMode = (Switch) view.findViewById(R.id.vr_mode); Switch preview = (Switch) view.findViewById(R.id.preview); Spinner resolutionFactor = (Spinner) view.findViewById(R.id.resolution_factor); resolutionFactor.setSelection(Integer.numberOfTrailingZeros(shader.getResolution())); resolutionFactor.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override// ww w . j a va2 s .co m public void onItemSelected(AdapterView<?> adapterView, View view, int pos, long id) { shader.setResolution(1 << pos); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); nameView.setText(shader.getName()); vrMode.setChecked(shader.getVrMode() == 1); vrMode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { shader.setVrMode(isChecked ? 1 : 0); } }); preview.setChecked(shader.getPreviewMode() == 1); preview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { shader.setPreviewMode(isChecked ? 1 : 0); } }); builder.setTitle(R.string.properties).setView(view) .setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { shader.setName(nameView.getText().toString()); mListener.onSave(shader); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mListener.onCancel(shader); } }); return builder.create(); }
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 w ww . j a v a2 s . c o 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.coinblesk.client.MainActivity.java
private void initSwitch(Menu menu) { MenuItem item = menu.findItem(R.id.myswitch); View view = item.getActionView(); final Switch mySwitch = (Switch) view.findViewById(R.id.switchAB); final AtomicReference<CountDownTimer> ref = new AtomicReference<>(); mySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override//from w w w. j a v a 2 s . c om public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { if (isChecked) { //enable BT ref.set(new CountDownTimer(30000, 1000) { int i = 0; public void onTick(final long millisUntilFinished) { mySwitch.setButtonDrawable( (i++ % 2) == 0 ? R.drawable.bluetooth_onon : R.drawable.bluetooth_on); mySwitch.setTextOn("" + millisUntilFinished / 1000); } public void onFinish() { mySwitch.setButtonDrawable(R.drawable.bluetooth_on); mySwitch.setChecked(false); } }); ref.get().start(); LocalBroadcastManager.getInstance(MainActivity.this) .sendBroadcast(new Intent(Constants.START_CLIENTS_ACTION)); } else { //mySwitch.setShowText(false); CountDownTimer tmp; if ((tmp = ref.getAndSet(null)) != null) { tmp.cancel(); } LocalBroadcastManager.getInstance(MainActivity.this) .sendBroadcast(new Intent(Constants.STOP_CLIENTS_ACTION)); } } }); }
From source file:ch.ethz.coss.nervousnet.hub.ui.SensorDisplayActivity.java
@Override public void updateActionBar() { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(R.layout.ab_nn, null); ActionBar actionBar;/*w w w . ja va2s . c o m*/ Switch mainSwitch; actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setCustomView(v); mainSwitch = (Switch) findViewById(R.id.mainSwitch); byte state = ((Application) getApplication()).getState(); NNLog.d("SensorDisplayActivity", "state = " + state); mainSwitch.setChecked(state == 0 ? false : true); mainSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { startStopSensorService(isChecked); } }); }
From source file:com.avalond.ad_blocak.main.StartFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_start, container, false); Switch switchOnBoot = (Switch) rootView.findViewById(R.id.switch_onboot); ImageView view = (ImageView) rootView.findViewById(R.id.start_button); TextView stateText = (TextView) rootView.findViewById(R.id.state_textview); stateText.setText(getString(AdVpnService.vpnStatusToTextId(AdVpnService.vpnStatus))); view.setOnLongClickListener(v -> { if (AdVpnService.vpnStatus != AdVpnService.VPN_STATUS_STOPPED) { Log.i(TAG, "Attempting to disconnect"); Intent intent = new Intent(getActivity(), AdVpnService.class); intent.putExtra("COMMAND", Command.STOP.ordinal()); getActivity().startService(intent); } else {//from w ww . j a v a 2 s. c om checkHostsFilesAndStartService(); } return true; }); switchOnBoot.setChecked(MainActivity.config.autoStart); switchOnBoot.setOnCheckedChangeListener((buttonView, isChecked) -> { MainActivity.config.autoStart = isChecked; FileHelper.writeSettings(getContext(), MainActivity.config); }); return rootView; }
From source file:support.plus.reportit.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Default config if (savedInstanceState != null) { // Restore value of members from saved state userName = savedInstanceState.getString(userName); userBossName = savedInstanceState.getString(userBossName); } else {/*from ww w.j ava2 s . co m*/ // Probably initialize members with default values for a new instance } super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar toolbar = (Toolbar) findViewById(R.id.settings_toolbar); setSupportActionBar(toolbar); toolbar.setTitle(R.string.app_name); toolbar.setNavigationIcon(R.drawable.ic_back); final TextView TextuserName = (TextView) findViewById(R.id.userName); final TextView TextuserBossName = (TextView) findViewById(R.id.userBossName); final EditText inuserName = (EditText) findViewById(R.id.inuserName); final EditText inuserBossName = (EditText) findViewById(R.id.inuserBossName); final Switch sNoti = (Switch) findViewById(R.id.sNoti); final Button btimePick = (Button) findViewById(R.id.btimePick); final Button bSave = (Button) findViewById(R.id.bSave); final Switch sfingerprint_activ = (Switch) findViewById(R.id.sfingerprint_activ); final Button bsetpassword = (Button) findViewById(R.id.bsetpassword); final Switch sdarkTheme = (Switch) findViewById(R.id.sdarkTheme); final Button bchooseRingtone = (Button) findViewById(R.id.bringtonePick); final SharedPreferences pref3 = getSharedPreferences("Theme", Context.MODE_PRIVATE); Boolean themeDark = pref3.getBoolean("darkTheme", false); if (themeDark == true) { sdarkTheme.setChecked(true); } else { sdarkTheme.setChecked(false); } sdarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { final SharedPreferences pref3 = getSharedPreferences("Theme", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref3.edit(); editor.putBoolean("darkTheme", true); editor.commit(); getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); // Now recreate for it to take effect // startActivity(getIntent()); recreate(); } else { SharedPreferences.Editor editor = pref3.edit(); editor.putBoolean("darkTheme", false); editor.commit(); getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_AUTO); // Now recreate for it to take effect // startActivity(getIntent()); recreate(); } } }); /* SECURITY SETTINGS */ final SharedPreferences pref1 = getSharedPreferences("Fingerprint", Context.MODE_PRIVATE); Boolean fingerprintSet = pref1.getBoolean("fingerprintSet", false); if (fingerprintSet == true) { sfingerprint_activ.setChecked(true); bsetpassword.setVisibility(View.VISIBLE); } else { sfingerprint_activ.setChecked(false); bsetpassword.setVisibility(View.GONE); } sfingerprint_activ.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { SharedPreferences.Editor editor = pref1.edit(); editor.putBoolean("fingerprintSet", true); editor.commit(); bsetpassword.setVisibility(View.VISIBLE); } else { SharedPreferences.Editor editor = pref1.edit(); editor.putBoolean("fingerprintSet", false); editor.commit(); bsetpassword.setVisibility(View.GONE); } } }); bsetpassword.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(SettingsActivity.this).title(R.string.set_password) .content(R.string.set_password_desc) .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) .inputRange(1, 10) .input(getString(R.string.password), "", new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog dialog, CharSequence input) { String name = String.valueOf(input); SharedPreferences pref1 = getSharedPreferences("Fingerprint", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref1.edit(); editor.putString("passwordSet", name); editor.commit(); return; } }).positiveText(R.string.set_password).negativeText(R.string.cancel).cancelable(false) .show(); } }); /* END SECURITY SETTINGS */ /* NOTIFICATION SETTINGS */ btimePick.setVisibility(View.GONE); sNoti.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { btimePick.setVisibility(View.VISIBLE); bchooseRingtone.setVisibility(View.VISIBLE); } else { btimePick.setVisibility(View.GONE); bchooseRingtone.setVisibility(View.GONE); } } }); final SharedPreferences pref4 = getApplicationContext().getSharedPreferences("userNotification", MODE_PRIVATE); Boolean notificationSet = pref4.getBoolean("alarmSet", false); if (notificationSet == true) { sNoti.setChecked(true); btimePick.setVisibility(View.VISIBLE); bchooseRingtone.setVisibility(View.VISIBLE); } else { sNoti.setChecked(false); btimePick.setVisibility(View.GONE); bchooseRingtone.setVisibility(View.GONE); } sNoti.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { SharedPreferences.Editor editor = pref4.edit(); editor.putBoolean("alarmSet", true); editor.commit(); btimePick.setVisibility(View.VISIBLE); bchooseRingtone.setVisibility(View.VISIBLE); } else { SharedPreferences.Editor editor = pref4.edit(); editor.putBoolean("alarmSet", false); editor.commit(); btimePick.setVisibility(View.GONE); bchooseRingtone.setVisibility(View.GONE); } } }); bchooseRingtone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, R.string.choose_ringtone); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); startActivityForResult(intent, 5); } }); btimePick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = new TimePickerFragment(); newFragment.show(getSupportFragmentManager(), "timePicker"); } }); /* END NOTIFICATION SETTINGS */ /* SAVE SETTINGS */ bSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String saveworkplace = "Student"; String saveuserBossName = "Boss"; saveworkplace = inuserName.getText().toString(); saveuserBossName = inuserBossName.getText().toString(); TextuserName.setText(getString(R.string.firm_name) + String.valueOf(saveworkplace)); TextuserBossName.setText(getString(R.string.instructor_name) + String.valueOf(saveuserBossName)); final SharedPreferences pref2 = getApplicationContext().getSharedPreferences("userData", MODE_APPEND); SharedPreferences.Editor editor = pref2.edit(); editor.putString("userName", saveworkplace); editor.putString("userBoss", saveuserBossName); editor.putBoolean("data_saved", true); editor.commit(); Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), "Data saved. Restart the app to see changes.", Snackbar.LENGTH_LONG); snackbar.show(); // finish(); startActivity(getIntent()); } }); final SharedPreferences pref2 = getApplicationContext().getSharedPreferences("userData", MODE_APPEND); if (pref2.getBoolean("data_saved", true)) { String TextuserNameString = pref2.getString("userName", ""); String TextuserBossNameString = pref2.getString("userBoss", ""); TextuserName.setText(getString(R.string.firm_name) + String.valueOf(TextuserNameString)); TextuserBossName.setText(getString(R.string.instructor_name) + String.valueOf(TextuserBossNameString)); inuserName.setVisibility(View.GONE); inuserBossName.setVisibility(View.GONE); bSave.setVisibility(View.GONE); } else { Toast toast = Toast.makeText(this, "No data saved", Toast.LENGTH_SHORT); toast.show(); } /* END SAVE SETTINGS */ }
From source file:org.jak_linux.dns66.main.StartFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_start, container, false); Switch switchOnBoot = (Switch) rootView.findViewById(R.id.switch_onboot); ImageView view = (ImageView) rootView.findViewById(R.id.start_button); view.setOnLongClickListener(new View.OnLongClickListener() { @Override/*w w w. j a v a2s. c om*/ public boolean onLongClick(View v) { if (AdVpnService.vpnStatus != AdVpnService.VPN_STATUS_STOPPED) { Log.i(TAG, "Attempting to disconnect"); Intent intent = new Intent(getActivity(), AdVpnService.class); intent.putExtra("COMMAND", org.jak_linux.dns66.vpn.Command.STOP.ordinal()); getActivity().startService(intent); } else { checkHostsFilesAndStartService(); } return true; } }); updateStatus(rootView, AdVpnService.vpnStatus); switchOnBoot.setChecked(MainActivity.config.autoStart); switchOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { MainActivity.config.autoStart = isChecked; FileHelper.writeSettings(getContext(), MainActivity.config); } }); return rootView; }
From source file:dynamite.zafroshops.app.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); EXTRA_ID = getApplicationContext().getPackageName() + ".id"; titles = new CharSequence[] { getString(R.string.title_section1), getString(R.string.title_section2), getString(R.string.title_section5) }; mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); NewZopOpenings = new ArrayList(); NewZopServices = new ArrayList(); depth = 1;/*ww w . j ava2s . c o m*/ locationToggleDefault = true; // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); SharedPreferences preferences = getPreferences(0); final SharedPreferences.Editor editor = preferences.edit(); Switch locationToggle = (Switch) findViewById(R.id.location_toggle); locationToggle.setChecked(preferences.getBoolean(StorageKeys.LOCATION_TOGGLE_KEY, locationToggleDefault)); locationToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { editor.putBoolean(StorageKeys.LOCATION_TOGGLE_KEY, b); editor.commit(); if (b) { getLocation(true); getAddress(true); } } }); if (!preferences.contains(StorageKeys.COUNTRY_KEY)) { editor.putString(StorageKeys.COUNTRY_KEY, ""); editor.commit(); } try { // Create the Mobile Service Client instance, using the provided // Mobile Service URL and key MobileClient = new MobileServiceClient(getString(R.string.azure_site), getString(R.string.azure_mobile_service_app_key), this); } catch (MalformedURLException ignored) { } NotificationsManager.handleNotifications(this, getString(R.string.google_api_name), PushHandler.class); registerWithNotificationHubs(); googleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); Bundle bundle = getIntent().getExtras(); if (bundle != null && bundle.containsKey(EXTRA_ID)) { nextMenu(ZopItemFragment.newInstance(bundle.getString(EXTRA_ID)), false, 100); } // setup ads adView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build(); adView.loadAd(adRequest); Interstitial = new InterstitialAd(this); Interstitial.setAdUnitId(getString(R.string.ads_interstitial_unit_id)); Interstitial.setAdListener(new AdListener() { @Override public void onAdClosed() { requestNewInterstitial(); } }); requestNewInterstitial(); // setup in app package if (!getResources().getBoolean(R.bool.debug)) { inAppHelper = new IabHelper(this, getString(R.string.inappkey)); inAppHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { return; } if (inAppHelper == null) { return; } inAppHelper.queryInventoryAsync(gotInventoryListener); } }); } DataVersion = 0; Versions = new Hashtable<>(); Counts = new Hashtable<>(); setDataVersion(); openHelpDialog(null); }