Class Flash

All Implemented Interfaces:
IFlashlight, EventListener, IGProp<GProp<?>[]>, IPropCnr, Cloneable

public class Flash extends PropCnr implements IFlashlight
This Flashlight or torch property is a container that holds information about client devices flashlight availability, state and intensity. The flashlight is only present with the iiziRun Cordova hybrid client. The intensity is currently only working with iOS.
Author:
Christopher Mindus
  • Constructor Details

    • Flash

      public Flash()
      Creates the flashlight properties without a name.
    • Flash

      public Flash(Atom atom)
      Creates the flashlight properties with a name.
      Parameters:
      atom - The atom name.
  • Method Details

    • onPropDispose

      protected void onPropDispose()
      Called when a property is disposed of by delete/remove in a container, or by the dispose method.

      The Property Container clears the structure of unsent communication requests to clear memory.

      This call is done just at the end of the delete/remove routine in the container, without synchronization.

      During this call, whatever components that e.g. the client needs to disposed of is done.

      Subclasses needing to perform some intelligent operations upon deletion should do it by overloading this method and always call the super.onPropDispose() method.

      Overrides:
      onPropDispose in class PropCnr
    • clone

      public Flash clone()
      Clones the properties.
      Overrides:
      clone in class PropCnr
    • onRemoteEvent

      public void onRemoteEvent(RemoteEvent event)
      Called when a remote property event should be processed by this property.
      Specified by:
      onRemoteEvent in interface IGProp<GProp<?>[]>
      Overrides:
      onRemoteEvent in class GProp<GProp<?>[]>
      Parameters:
      event - The remote event.
    • isSupported

      public boolean isSupported()
      Verifies if the flashlight is supported for the client session.
      Specified by:
      isSupported in interface IFlashlight
      Returns:
      The flashlight support flag. If true it only means that the flashlight could potentially be controlled programmatically, not that the user has allowed or enabled access to it.
    • isIntensitySupported

      public boolean isIntensitySupported()
      Checks if the flashlight supports intensity levels.
      Specified by:
      isIntensitySupported in interface IFlashlight
      Returns:
      true if intensity is supported, currently only iOS using iiziRun, false otherwise.
    • getClientSession

      public IClientSessionGyro getClientSession()
      Gets the client session associated with this flashlight instance.
      Specified by:
      getClientSession in interface IFlashlight
      Returns:
      The client session, or null if it is disposed of already. Please note that the client session might be returned as non-null but that it is currently in dispose operation.
    • addListener

      public boolean addListener(IFlashlightListener listener)
      Adds a listener to the flashlight that receives notifications of the flashlight state and return code of operations.
      Specified by:
      addListener in interface IFlashlight
      Parameters:
      listener - The listener instance for notifications.
      Returns:
      true for success, false if listener is already registered.
    • removeListener

      public boolean removeListener(IFlashlightListener listener)
      Removes a listener from the flashlight. When the last listener is removed, the flashlight will automatically be switched off (using IFlashlight.Operation.SWITCH_OFF, not IFlashlight.Operation.AUTO_SWITCH_OFF). This is also valid when the client session is disposed of, but then with the operation IFlashlight.Operation.AUTO_SWITCH_OFF.
      Specified by:
      removeListener in interface IFlashlight
      Parameters:
      listener - The listener instance for notifications.
      Returns:
      true for success, false if listener is not registered.
    • getAsyncState

      public boolean getAsyncState()
      Gets the current availability and state of the flashlight, if successful, it will cause the registered listener(s) to be invoked asynchronously. The first time this method is invoked for a client session and the iiziRun instance, the user may be asked to allow programmatic operational control of the flashlight. Please note that the flashlight is generally "connected" to the camera, so some devices may use the front camera rather than the back. The user might also be asked to allow camera operational control (instead of just the flashlight).
      Specified by:
      getAsyncState in interface IFlashlight
      Returns:
      true if flashlight will be switched on, false if the flashlight is not supported, not available, or client is disposed of.
      See Also:
    • isAvailable

      public boolean isAvailable()
      Verifies if the flashlight has been verified as available by a previous call to getAsyncState().
      Specified by:
      isAvailable in interface IFlashlight
      Returns:
      true if the flashlight has been made available for programmatic use, false if such a request has been denied by the user or not requested before using getAsyncState().
    • isSwitchedOn

      public boolean isSwitchedOn()
      Gets the flashlight switched on state, initially set to false.
      Specified by:
      isSwitchedOn in interface IFlashlight
      Returns:
      The flashlight switched on state. Please note that this value may not be accurate if getAsyncState() not yet has invoked its listeners, or that getAsyncState() not has been called.
    • getIntensity

      public double getIntensity()
      Gets the current flashlight intensity, initially set to 1.0, but also set at the last flashlight switchOn(double).
      Specified by:
      getIntensity in interface IFlashlight
      Returns:
      The intensity with a value range of 0.0 to 1.0, only working for iOS.
    • setIntensity

      public boolean setIntensity(double intensity) throws IllegalArgumentException
      Gets the current flashlight intensity, initially set to 1.0, but also set at the last flashlight switchOn(double).
      Specified by:
      setIntensity in interface IFlashlight
      Returns:
      true if changed, false for no change.
      Throws:
      IllegalArgumentException - If the intensity is not in the range of 0.0 to 1.0.
    • switchOn

      public boolean switchOn(double intensity) throws IllegalArgumentException
      Switches on the flashlight with the requested intensity, a value between 0.0 (darkest) and 1.0 (brightest). The value is only processed for iOS.
      Specified by:
      switchOn in interface IFlashlight
      Returns:
      true if the operation is going to issue a later callback using the function registered using addListener(IFlashlightListener), or false if the flashlight is not present or the client session is disposed of.
      Throws:
      IllegalArgumentException - If the intensity is not in the range of 0.0 to 1.0.
    • switchOff

      public boolean switchOff()
      Switches off the flashlight.
      Specified by:
      switchOff in interface IFlashlight
      Returns:
      true if the operation is going to issue a later callback using the function registered using addListener(IFlashlightListener), or false if the flashlight is not present or the client session is disposed of.