-
- All Implemented Interfaces:
-
com.otaliastudios.cameraview.engine.action.Action
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP) 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 intgetState()Returns the current state. final voidsetState(int newState)Called by subclasses to notify of their state. final voidstart(@NonNull() ActionHolder holder)Starts this action. final voidabort(@NonNull() ActionHolder holder)Aborts this action. voidonCaptureStarted(@NonNull() ActionHolder holder, @NonNull() CaptureRequest request)Called from onCaptureStarted. voidonCaptureProgressed(@NonNull() ActionHolder holder, @NonNull() CaptureRequest request, @NonNull() CaptureResult result)Called from onCaptureProgressed. voidonCaptureCompleted(@NonNull() ActionHolder holder, @NonNull() CaptureRequest request, @NonNull() TotalCaptureResult result)Called from onCaptureCompleted. booleanisCompleted()Whether this action has reached the completed state. voidaddCallback(@NonNull() ActionCallback callback)Adds an ActionCallback to receive statechange events. voidremoveCallback(@NonNull() ActionCallback callback)Removes a previously added callback. -
-
Method Detail
-
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
-
start
final void start(@NonNull() ActionHolder holder)
Starts this action.
- Parameters:
holder- the holder
-
abort
final void abort(@NonNull() ActionHolder holder)
Aborts this action.
- Parameters:
holder- the holder
-
onCaptureStarted
@CallSuper() void onCaptureStarted(@NonNull() ActionHolder holder, @NonNull() CaptureRequest request)
Called from onCaptureStarted.
- Parameters:
holder- the holderrequest- the request
-
onCaptureProgressed
void onCaptureProgressed(@NonNull() ActionHolder holder, @NonNull() CaptureRequest request, @NonNull() CaptureResult result)
Called from onCaptureProgressed.
- Parameters:
holder- the holderrequest- the requestresult- the result
-
onCaptureCompleted
void onCaptureCompleted(@NonNull() ActionHolder holder, @NonNull() CaptureRequest request, @NonNull() 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(@NonNull() ActionCallback callback)
Adds an ActionCallback to receive statechange events.
- Parameters:
callback- a callback
-
removeCallback
void removeCallback(@NonNull() ActionCallback callback)
Removes a previously added callback.
- Parameters:
callback- a callback
-
-
-
-