Package com.microblink.blinkid.fragment.overlay

# Class BaseOverlayController

java.lang.Object
com.microblink.blinkid.fragment.overlay.BaseOverlayController

All Implemented Interfaces:
  `ScanningOverlay`, `ScanResultListener`

Direct Known Subclasses:
  `BlinkIdOverlayController`

public abstract class BaseOverlayController extends Object implements ScanningOverlay

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected android.app.AlertDialog`
  `errorDialog`
  `protected android.os.Handler`
  `handler`
  `protected OverlayState`
  `overlayState`
  `protected RecognizerRunnerFragment`
  `recognizerRunnerFragment`
  `protected RecognizerRunnerView`
  `recognizerRunnerView`
  `protected ScanResultListener`
  `scanResultListener`
  `protected ScanSoundPlayer`
  `scanSoundPlayer`
  `protected TorchController`
  `torchController`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `BaseOverlayController(ScanResultListener scanResultListener)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract int`
  `getBeepSoundResourceId()`
  `android.content.Context`
  `getContext()`
  Returns context of the parent activity, after the RecognizerRunnerFragment is attached.
  `protected abstract int`
  `getSplashScreenLayoutId()`
  `protected void`
  `onCameraAutofocusFailed()`
  `protected void`
  `onFragmentConfigurationChanged(android.content.res.Configuration newConfig)`
  `protected void`
  `onFragmentCreated(android.os.Bundle savedInstanceState)`
  `protected void`
  `onFragmentDestroyed()`
  `protected void`
  `onFragmentPaused()`
  `protected void`
  `onFragmentResumed()`
  `protected void`
  `onFragmentSaveInstanceState(android.os.Bundle outState)`
  `protected void`
  `onFragmentStarted()`
  `protected void`
  `onFragmentStopped()`
  `void`
  `onFrameRecognitionDone(RecognitionSuccessType recognitionSuccessType)`
  Called for each camera frame, after the recognition has been completed.
  `void`
  `onRecognizerRunnerFragmentAttached(RecognizerRunnerFragment recognizerRunnerFragment, android.app.Activity activity)`
  Called after `RecognizerRunnerFragment` gets attached to its host activity.
  `void`
  `onRecognizerRunnerViewCreated(RecognizerRunnerFragment recognizerRunnerFragment)`
  Called when `RecognizerRunnerView` has been created within given `RecognizerRunnerFragment`.
  `void`
  `onUnrecoverableError(Throwable throwable)`
  This method is called when the scanning cannot be performed because of an error.
  `void`
  `pauseScanning()`
  If the `RecognizerRunnerView` has been created, pauses the scanning loop by calling `RecognizerRunnerView.pauseScanning()`.
  `void`
  `resumeScanning()`
  If the `RecognizerRunnerView` has been created, resumes the scanning loop (that has been paused) by calling `RecognizerRunnerView.resumeScanning(boolean)` }.
  `protected void`
  `setMeteringAreas()`
  `protected abstract boolean`
  `shouldResetStateOnRecognizerResume()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface com.microblink.blinkid.view.recognition.ScanResultListener

  `onScanningDone`

- ## Field Details

  - ### scanResultListener

    @NonNull protected ScanResultListener scanResultListener

  - ### overlayState

    @NonNull protected OverlayState overlayState

  - ### recognizerRunnerFragment

    @Nullable protected RecognizerRunnerFragment recognizerRunnerFragment

  - ### recognizerRunnerView

    @Nullable protected RecognizerRunnerView recognizerRunnerView

  - ### handler

    @NonNull protected android.os.Handler handler

  - ### errorDialog

    @Nullable protected android.app.AlertDialog errorDialog

  - ### scanSoundPlayer

    @NonNull protected ScanSoundPlayer scanSoundPlayer

  - ### torchController

    @NonNull protected TorchController torchController

- ## Constructor Details

  - ### BaseOverlayController

    protected BaseOverlayController(@NonNull ScanResultListener scanResultListener)

- ## Method Details

  - ### onRecognizerRunnerViewCreated

    @CallSuper public void onRecognizerRunnerViewCreated(@NonNull RecognizerRunnerFragment recognizerRunnerFragment)
    Description copied from interface: `ScanningOverlay`
    Called when `RecognizerRunnerView` has been created within given `RecognizerRunnerFragment`. You can use `RecognizerRunnerFragment.getRecognizerRunnerView()` to get the created `RecognizerRunnerView` and configure it. The most important thing you should do in this method is to set `RecognizerBundle` to created `RecognizerRunnerView` using `RecognizerRunnerView.setRecognizerBundle(RecognizerBundle)`. You can also register various callbacks to `RecognizerRunnerView`, except `CameraEventsListener` (using `BaseCameraView.setCameraEventsListener(CameraEventsListener)`) and `ScanResultListener` (using `RecognizerRunnerView.setScanResultListener(ScanResultListener)` - those two listeners will be set to `RecognizerRunnerView` within `RecognizerRunnerFragment` after calling this method - if you need to observe camera events within `RecognizerRunnerFragment`, you can set your own `BaseCameraEventsListener` to it with `RecognizerRunnerFragment.setCameraEventsListener(BaseCameraEventsListener)`. In this method, you can also access `RecognizerRunnerFragment`'s content layout with method `RecognizerRunnerFragment.getContentLayout()` and add your views to it.
    Specified by:
      `onRecognizerRunnerViewCreated` in interface `ScanningOverlay`
    Parameters:
      `recognizerRunnerFragment` - `RecognizerRunnerFragment` within which `RecognizerRunnerView` has been created.

  - ### resumeScanning

    @AnyThread @CallSuper public void resumeScanning()
    Description copied from interface: `ScanningOverlay`
    If the `RecognizerRunnerView` has been created, resumes the scanning loop (that has been paused) by calling `RecognizerRunnerView.resumeScanning(boolean)` }.

    If the `RecognizerRunnerView` has not been created yet, does nothing.

    Specified by:
      `resumeScanning` in interface `ScanningOverlay`
    See Also:
      - `RecognizerRunnerView.resumeScanning(boolean)`

  - ### shouldResetStateOnRecognizerResume

    protected abstract boolean shouldResetStateOnRecognizerResume()

  - ### pauseScanning

    @AnyThread @CallSuper public void pauseScanning()
    Description copied from interface: `ScanningOverlay`
    If the `RecognizerRunnerView` has been created, pauses the scanning loop by calling `RecognizerRunnerView.pauseScanning()`. But keeps camera active. If the `RecognizerRunnerView` has not been created yet, does nothing.

    You can resume scanning by calling `ScanningOverlay.resumeScanning()`.

    Specified by:
      `pauseScanning` in interface `ScanningOverlay`
    See Also:
      - `RecognizerRunnerView.pauseScanning()`

  - ### getBeepSoundResourceId

    protected abstract int getBeepSoundResourceId()

  - ### onRecognizerRunnerFragmentAttached

    @CallSuper public void onRecognizerRunnerFragmentAttached(@NonNull RecognizerRunnerFragment recognizerRunnerFragment, @NonNull android.app.Activity activity)
    Description copied from interface: `ScanningOverlay`
    Called after `RecognizerRunnerFragment` gets attached to its host activity. This happens before `RecognizerRunnerFragment.onCreateView(LayoutInflater, ViewGroup, Bundle)` which internally invokes `ScanningOverlay.onRecognizerRunnerViewCreated(RecognizerRunnerFragment)`. This means that at the time this method is invoked, methods like `RecognizerRunnerFragment.getRecognizerRunnerView()` or `RecognizerRunnerFragment.getContentLayout()` will return null. However, this is a good place to register your `LifecycleObserver` with `RecognizerRunnerFragment.registerLifecycleObserver(LifecycleObserver)` if your overlay needs to be notified about lifecycle events of `RecognizerRunnerFragment`.
    Specified by:
      `onRecognizerRunnerFragmentAttached` in interface `ScanningOverlay`
    Parameters:
      `recognizerRunnerFragment` - `RecognizerRunnerFragment` that has been attached to host activity.
      `activity` - `Activity` to which `RecognizerRunnerFragment` has been attached.

  - ### getContext

    @Nullable public android.content.Context getContext()
    Returns context of the parent activity, after the RecognizerRunnerFragment is attached.
    Returns:
      context of the parent activity or `null` if the recognizer runner fragment has not been attached yet.

  - ### getSplashScreenLayoutId

    @LayoutRes protected abstract int getSplashScreenLayoutId()

  - ### setMeteringAreas

    protected void setMeteringAreas()

  - ### onFragmentCreated

    protected void onFragmentCreated(@Nullable android.os.Bundle savedInstanceState)

  - ### onFragmentStarted

    protected void onFragmentStarted()

  - ### onFragmentResumed

    protected void onFragmentResumed()

  - ### onFragmentPaused

    protected void onFragmentPaused()

  - ### onFragmentStopped

    protected void onFragmentStopped()

  - ### onFragmentDestroyed

    protected void onFragmentDestroyed()

  - ### onFragmentConfigurationChanged

    protected void onFragmentConfigurationChanged(@NonNull android.content.res.Configuration newConfig)

  - ### onFragmentSaveInstanceState

    protected void onFragmentSaveInstanceState(@Nullable android.os.Bundle outState)

  - ### onCameraAutofocusFailed

    protected void onCameraAutofocusFailed()

  - ### onUnrecoverableError

    public void onUnrecoverableError(@NonNull Throwable throwable)
    Description copied from interface: `ScanResultListener`
    This method is called when the scanning cannot be performed because of an error.
    Specified by:
      `onUnrecoverableError` in interface `ScanResultListener`
    Parameters:
      `throwable` - type of error

  - ### onFrameRecognitionDone

    public void onFrameRecognitionDone(RecognitionSuccessType recognitionSuccessType)
    Description copied from interface: `ScanningOverlay`
    Called for each camera frame, after the recognition has been completed.
    Specified by:
      `onFrameRecognitionDone` in interface `ScanningOverlay`
    Parameters:
      `recognitionSuccessType` - frame recognition status.