List of usage examples for android.widget Switch Switch
Switch
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
private void createModeSwitcher() { LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater(); modeSwitcher = (com.almalence.ui.Switch.Switch) inflator .inflate(R.layout.plugin_capture_standard_modeswitcher, null, false); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); ModePreference = prefs.getString("modeVideoDROPref", "1"); modeSwitcher.setTextOn(ApplicationScreen.instance.getString(R.string.Pref_Video_DRO_ON)); modeSwitcher.setTextOff(ApplicationScreen.instance.getString(R.string.Pref_Video_DRO_OFF)); modeSwitcher.setChecked(ModePreference.compareTo("0") == 0 ? true : false); modeSwitcher.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override/*from w w w . j a v a2 s .co m*/ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(ApplicationScreen.getMainContext()); if (isChecked) { ModePreference = "0"; if (CameraController.isNexus6) { Toast.makeText(ApplicationScreen.getMainContext(), "Not suported currently on your device. Will be available later.", Toast.LENGTH_LONG).show(); ModePreference = "1"; modeSwitcher.setChecked(false); return; } } else { ModePreference = "1"; } SharedPreferences.Editor editor = prefs.edit(); editor.putString("modeVideoDROPref", ModePreference); editor.commit(); if (modeDRO()) { int quality = Integer.parseInt(prefs.getString( CameraController.getCameraIndex() == 0 ? ApplicationScreen.sImageSizeVideoBackPref : ApplicationScreen.sImageSizeVideoFrontPref, DEFAULT_VIDEO_QUALITY)); if (quality > CamcorderProfile.QUALITY_720P || maxQuality()) { quality = CamcorderProfile.QUALITY_720P; quickControlIconID = R.drawable.gui_almalence_video_720; editor.putString( CameraController.getCameraIndex() == 0 ? ApplicationScreen.sImageSizeVideoBackPref : ApplicationScreen.sImageSizeVideoFrontPref, String.valueOf(quality)); editor.commit(); VideoCapturePlugin.this.refreshQuickControl(); } } try { CameraController.stopCameraPreview(); setCameraPreviewSize(); if (VideoCapturePlugin.this.modeDRO()) { takePictureButton.setVisibility(View.GONE); timeLapseButton.setVisibility(View.GONE); ApplicationScreen.instance.showOpenGLLayer(2); ApplicationScreen.instance.glSetRenderingMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); } else { if (!CameraController.isRemoteCamera()) { if (displayTakePicture) takePictureButton.setVisibility(View.VISIBLE); timeLapseButton.setVisibility(View.VISIBLE); } droEngine.onPause(); ApplicationScreen.instance.hideOpenGLLayer(); if (!CameraController.isUseCamera2()) { CameraController.setupCamera(ApplicationScreen.getPreviewSurfaceHolder(), true); } CameraController.startCameraPreview(); } } catch (final Exception e) { Log.e(TAG, Util.toString(e.getStackTrace(), '\n')); e.printStackTrace(); } } }); }