@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if ((getArguments() != null) && !files.isEmpty()) { currentIndex = getArguments().getInt(INDEX_KEY); final SVFileRest svFileRest = files.get(currentIndex); try { picasso .load(svFileRest.getUrl()) .into( image, new Callback() { @Override public void onSuccess() { try { image.setZoom(1); progressBar.setVisibility(View.GONE); } catch (Exception e) { // } } @Override public void onError() { try { progressBar.setVisibility(View.GONE); image.setImageDrawable( getContext().getResources().getDrawable(R.drawable.ic_img_fail)); } catch (Exception e) { // } } }); } catch (Exception e) { Log.d(TAG, "", e); } } // } else { // if (image != null) // // image.setImageDrawable(getSherlockActivity().getResources().getDrawable(R.drawable.ic_img_fail)); // } image.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { eventBus.post(v); } }); }
@Override public void onClick(View view) { if (view.getId() == R.id.rootFrame) { if (mCamera == null) return; mCamera.cancelAutoFocus(); mCamera.autoFocus( new Camera.AutoFocusCallback() { @Override public void onAutoFocus(boolean success, Camera camera) { if (!success) Toast.makeText(getActivity(), "Unable to auto-focus!", Toast.LENGTH_SHORT).show(); } }); } else { super.onClick(view); } }
@Override public void stopRecordingVideo(final boolean reachedZero) { super.stopRecordingVideo(reachedZero); if (mInterface.hasLengthLimit() && mInterface.shouldAutoSubmit() && (mInterface.getRecordingStart() < 0 || mMediaRecorder == null)) { stopCounter(); if (mCamera != null) { try { mCamera.lock(); } catch (Throwable t) { t.printStackTrace(); } } releaseRecorder(); closeCamera(); mButtonFacing.postDelayed( new Runnable() { @Override public void run() { mInterface.onShowPreview(mOutputUri, reachedZero); } }, 100); return; } if (mCamera != null) mCamera.lock(); releaseRecorder(); closeCamera(); if (!mInterface.didRecord()) mOutputUri = null; mButtonVideo.setImageDrawable(VC.get(this, R.drawable.mcam_action_capture)); if (!CameraUtil.isArcWelder()) mButtonFacing.setVisibility(View.VISIBLE); if (mInterface.getRecordingStart() > -1 && getActivity() != null) mInterface.onShowPreview(mOutputUri, reachedZero); stopCounter(); }
@Override public boolean startRecordingVideo() { super.startRecordingVideo(); if (prepareMediaRecorder()) { try { // UI mButtonVideo.setImageDrawable(VC.get(this, R.drawable.mcam_action_stop)); if (!CameraUtil.isArcWelder()) mButtonFacing.setVisibility(View.GONE); // Only start counter if count down wasn't already started if (!mInterface.hasLengthLimit()) { mInterface.setRecordingStart(System.currentTimeMillis()); startCounter(); } // Start recording mMediaRecorder.start(); mButtonVideo.setEnabled(false); mButtonVideo.postDelayed( new Runnable() { @Override public void run() { mButtonVideo.setEnabled(true); } }, 200); return true; } catch (Throwable t) { t.printStackTrace(); mInterface.setRecordingStart(-1); stopRecordingVideo(false); throwError(new Exception("Failed to start recording: " + t.getMessage(), t)); } } return false; }
@Override public void onResume() { super.onResume(); openCamera(); }
@Override public void onDestroyView() { super.onDestroyView(); mPreviewFrame = null; }
@Override public void onViewCreated(final View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mPreviewFrame = (RelativeLayout) view.findViewById(R.id.rootFrame); mPreviewFrame.setOnClickListener(this); }
@Override public void onPause() { if (mCamera != null) mCamera.lock(); super.onPause(); }