private void toggleCamera(boolean isNeedEnableCam) { // TODO temporary insertion will be removed when GLVideoView will be fixed DisplayMetrics displaymetrics = new DisplayMetrics(); displaymetrics.setToDefaults(); ViewGroup.LayoutParams layoutParams = imgMyCameraOff.getLayoutParams(); layoutParams.height = localVideoView.getHeight(); layoutParams.width = localVideoView.getWidth(); imgMyCameraOff.setLayoutParams(layoutParams); Log.d( TAG, "Width is: " + imgMyCameraOff.getLayoutParams().width + " height is:" + imgMyCameraOff.getLayoutParams().height); if (SessionManager.getCurrentSession() != null) { SessionManager.getCurrentSession().setVideoEnabled(isNeedEnableCam); cameraToggle.setChecked(isNeedEnableCam); if (isNeedEnableCam) { Log.d(TAG, "Camera is on"); switchCameraToggle.setVisibility(View.VISIBLE); imgMyCameraOff.setVisibility(View.INVISIBLE); } else { Log.d(TAG, "Camera is off"); switchCameraToggle.setVisibility(View.INVISIBLE); imgMyCameraOff.setVisibility(View.VISIBLE); } } }
@Override public void onClick(View v) { super.onClick(v); if (v.getId() == R.id.switchCameraToggle) { if (SessionManager.getCurrentSession() != null) { SessionManager.getCurrentSession() .switchCapturePosition( new Runnable() { @Override public void run() {} }); } } else if (v.getId() == R.id.switchCameraToggle) { if (SessionManager.getCurrentSession() != null) { if (cameraState != CameraState.DISABLED_FROM_USER) { toggleCamera(false); cameraState = CameraState.DISABLED_FROM_USER; } else { toggleCamera(true); cameraState = CameraState.ENABLED_FROM_USER; } } } // switch (v.getId()) { // case R.id.switchCameraToggle: // if (SessionManager.getCurrentSession() != null) { // SessionManager.getCurrentSession().switchCapturePosition(new Runnable() { // @Override // public void run() { // } // }); // } // break; // case R.id.cameraToggle: // if (SessionManager.getCurrentSession() != null) { // if (cameraState != CameraState.DISABLED_FROM_USER) { // toggleCamera(false); // cameraState = CameraState.DISABLED_FROM_USER; // } else { // toggleCamera(true); // cameraState = CameraState.ENABLED_FROM_USER; // } // } // break; // default: // break; // } }