public class ScannerViewFragment extends CameraPreviewCutoutFragment implements ScannerValidator.ScannerCoreListener
Self-contained fragment for scanning for QR codes from the camera. This fragment must be created using the #init method with appropriate parameters. Once created, it can be attached and used as any other fragment.
Activities hosting this fragment must implement the OnQrCodeFoundListener interface. This provides a single callback when a QR code is found and read. When called, the camera will be paused on the captured code, and the activity is free to control this fragment's UI further using #showWaitingFeedback, #showFailureFeedback, #showSuccessFeedback, or to restart the capture using #restart.| Modifier and Type | Class and Description |
|---|---|
static interface |
ScannerViewFragment.OnQrCodeFoundListener
Callback API which must be implemented by Activities hosting this fragment.
|
TEXT_ID_EMPTY| Constructor and Description |
|---|
ScannerViewFragment() |
| Modifier and Type | Method and Description |
|---|---|
protected CameraViewPresenter |
createPresenter() |
protected int |
getNumCameraBuffers() |
static ScannerViewFragment |
init()
ScannerViewFragment initialiser
|
static ScannerViewFragment |
init(int scanningInstructionMessage)
ScannerViewFragment initialiser
|
static ScannerViewFragment |
init(int scanningInstructionMessage,
java.lang.String animationAssetsFolder,
java.lang.String animationJsonFilePath)
ScannerViewFragment initialiser
|
static ScannerViewFragment |
init(int scanningInstructionMessage,
java.lang.String animationAssetsFolder,
java.lang.String animationJsonFilePath,
boolean disableAutomaticCameraStartStop) |
void |
onAttach(android.app.Activity activity) |
protected void |
onCameraPreviewReady() |
void |
onCodeDetected(java.lang.String data)
Called after #processFrameAr when exactly one QR code is detected in the current image.
|
void |
onCodeDetectionFailed(int errorStatus)
Called after #processFrameAr or in response to sensor changes when one or more error
conditions are met.
|
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState) |
void |
onDetach() |
protected void |
onHideScanningInstructionsButtonClick() |
void |
onPause() |
void |
onResume() |
void |
onShowScanningInstructions() |
void |
recycleBuffer(byte[] buffer)
Called when a frame previously supplied by #processFrameAr is no longer referenced, so can
be released.
|
void |
setQrCodeFoundListener(ScannerViewFragment.OnQrCodeFoundListener qrCodeFoundListener) |
protected boolean |
shouldDisableAutomaticCameraStartStop()
It will be called in
CameraPreviewFragment.onResume() and CameraPreviewFragment.onPause()
to determine whether the creation of camera should be handled automatically. |
void |
showSuccessFeedback(int resId) |
void |
showWaitingFeedback(int resId) |
void |
startCamera()
Starts the camera and the the cancel continuous focus timer.
|
void |
stopCamera()
Stops the camera and the the cancel continuous focus timer.
|
createCameraOverlay, getCameraViewContainer, hideFocusArea, onCameraOpenFailed, onCreate, onDestroy, onPreviewFrame, restart, setScanningInstructionsMessage, setStatusText, showFailureFeedback, showFocusArea, showNoFeedback, showStaticFrameImage, updateOverlayForCameraFaileddisableContinuousAutoFocus, generateHapticFeedback, initCamera, isContinuousAutoFocus, onCameraOpen, onCameraPreviewCreated, releaseCamera, releaseCameraBuffer, setLowResPreview, updateFocusAreadump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroyOptionsMenu, onDestroyView, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onSaveInstanceState, onStart, onStop, onViewCreated, onViewStateRestored, postponeEnterTransition, registerForContextMenu, requestPermissions, requireActivity, requireContext, requireFragmentManager, requireHost, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenupublic static ScannerViewFragment init()
public static ScannerViewFragment init(@StringRes int scanningInstructionMessage)
scanningInstructionMessage - instruction message displayed when the user try to scan for the first timepublic static ScannerViewFragment init(@StringRes int scanningInstructionMessage, @Nullable java.lang.String animationAssetsFolder, @Nullable java.lang.String animationJsonFilePath)
scanningInstructionMessage - instruction message displayed when the user try to scan for the first timeanimationAssetsFolder - animation asset folder to be used for the instructional message animation.animationJsonFilePath - animation json file to be used for the instructional message animation.public static ScannerViewFragment init(@StringRes int scanningInstructionMessage, @Nullable java.lang.String animationAssetsFolder, @Nullable java.lang.String animationJsonFilePath, boolean disableAutomaticCameraStartStop)
public void setQrCodeFoundListener(ScannerViewFragment.OnQrCodeFoundListener qrCodeFoundListener)
public android.view.View onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState)
onCreateView in class CameraPreviewCutoutFragmentpublic void startCamera()
throws java.lang.IllegalStateException
IllegalStateException will be thrown.java.lang.IllegalStateException - When this method is called when the fragment has not been called
with ScannerViewFragment.disableAutomaticCameraStartStop set to truepublic void stopCamera()
IllegalStateException will be thrown.java.lang.IllegalStateException - When this method is called when the fragment has not been called
with ScannerViewFragment.disableAutomaticCameraStartStop set to truepublic void onAttach(android.app.Activity activity)
onAttach in class android.support.v4.app.Fragmentpublic void onDetach()
onDetach in class android.support.v4.app.Fragmentpublic void onResume()
onResume in class CameraPreviewCutoutFragmentprotected int getNumCameraBuffers()
getNumCameraBuffers in class com.yoti.mobile.android.camera.ui.CameraPreviewFragmentpublic void onPause()
onPause in class CameraPreviewCutoutFragmentprotected CameraViewPresenter createPresenter()
createPresenter in class CameraPreviewCutoutFragmentprotected void onHideScanningInstructionsButtonClick()
onHideScanningInstructionsButtonClick in class CameraPreviewCutoutFragmentprotected void onCameraPreviewReady()
onCameraPreviewReady in class com.yoti.mobile.android.camera.ui.CameraPreviewFragmentpublic void onCodeDetected(java.lang.String data)
ScannerValidator.ScannerCoreListeneronCodeDetected in interface ScannerValidator.ScannerCoreListenerpublic void onCodeDetectionFailed(int errorStatus)
ScannerValidator.ScannerCoreListeneronCodeDetectionFailed in interface ScannerValidator.ScannerCoreListenererrorStatus - bitmask of sensor or picture errors.public void recycleBuffer(byte[] buffer)
ScannerValidator.ScannerCoreListenerrecycleBuffer in interface ScannerValidator.ScannerCoreListenerpublic void onShowScanningInstructions()
onShowScanningInstructions in interface ScannerValidator.ScannerCoreListenerprotected boolean shouldDisableAutomaticCameraStartStop()
CameraPreviewFragment.onResume() and CameraPreviewFragment.onPause()
to determine whether the creation of camera should be handled automatically.shouldDisableAutomaticCameraStartStop in class com.yoti.mobile.android.camera.ui.CameraPreviewFragmentCameraPreviewFragment.initCamera(),
CameraPreviewFragment.releaseCamera()public void showWaitingFeedback(int resId)
public void showSuccessFeedback(int resId)