-
- All Implemented Interfaces:
-
com.otaliastudios.cameraview.engine.action.Action
public abstract class BaseAction implements Action
The base implementation of Action that should always be subclassed, instead of implementing the root interface itself. It holds a list of callbacks and dispatches events to them, plus it cares about its own lifecycle: - when start is called, we add ourselves to the holder list - when STATE_COMPLETED is reached, we remove ouverselves from the holder list This is very important in all cases.
-
-
Field Summary
Fields Modifier and Type Field Description private intstate
-
Method Summary
Modifier and Type Method Description final voidstart(ActionHolder holder)Starts this action. final voidabort(ActionHolder holder)Aborts this action. voidonCaptureStarted(ActionHolder holder, CaptureRequest request)Called from onCaptureStarted. voidonCaptureProgressed(ActionHolder holder, CaptureRequest request, CaptureResult result)Called from onCaptureProgressed. voidonCaptureCompleted(ActionHolder holder, CaptureRequest request, TotalCaptureResult result)Called from onCaptureCompleted. booleanisCompleted()Whether this action has reached the completed state. voidaddCallback(ActionCallback callback)Adds an ActionCallback to receive statechange events. voidremoveCallback(ActionCallback callback)Removes a previously added callback. final intgetState()Returns the current state. final voidsetState(int newState)Called by subclasses to notify of their state. -
-
Method Detail
-
start
final void start(ActionHolder holder)
Starts this action.
- Parameters:
holder- the holder
-
abort
final void abort(ActionHolder holder)
Aborts this action.
- Parameters:
holder- the holder
-
onCaptureStarted
@CallSuper() void onCaptureStarted(ActionHolder holder, CaptureRequest request)
Called from onCaptureStarted.
- Parameters:
holder- the holderrequest- the request
-
onCaptureProgressed
void onCaptureProgressed(ActionHolder holder, CaptureRequest request, CaptureResult result)
Called from onCaptureProgressed.
- Parameters:
holder- the holderrequest- the requestresult- the result
-
onCaptureCompleted
void onCaptureCompleted(ActionHolder holder, CaptureRequest request, TotalCaptureResult result)
Called from onCaptureCompleted.
- Parameters:
holder- the holderrequest- the requestresult- the result
-
isCompleted
boolean isCompleted()
Whether this action has reached the completed state.
-
addCallback
void addCallback(ActionCallback callback)
Adds an ActionCallback to receive statechange events.
- Parameters:
callback- a callback
-
removeCallback
void removeCallback(ActionCallback callback)
Removes a previously added callback.
- Parameters:
callback- a callback
-
getState
final int getState()
Returns the current state.
-
setState
final void setState(int newState)
Called by subclasses to notify of their state. If state is STATE_COMPLETED,this removes this action from the holder.
- Parameters:
newState- new state
-
-
-
-