public abstract static class State.ChangeEvent<T_State extends State> extends Event
DeviceStateListener.StateEvent
and ManagerStateListener.StateEvent
.Modifier | Constructor and Description |
---|---|
protected |
ChangeEvent(int oldStateBits,
int newStateBits,
int intentMask) |
Modifier and Type | Method and Description |
---|---|
boolean |
didEnter(T_State state)
Convenience forwarding of
State.didEnter(int, int) . |
boolean |
didEnterAll(T_State... states)
|
boolean |
didEnterAny(T_State... states)
|
boolean |
didExit(T_State state)
Convenience forwarding of
State.didExit(int, int) . |
boolean |
didExitAll(T_State... states)
|
boolean |
didExitAny(T_State... states)
|
int |
enterMask()
Returns all the states that were entered as a bit mask.
|
int |
exitMask()
Returns all the states that were exited as a bit mask.
|
State.ChangeIntent |
getIntent(T_State state)
Returns the intention behind the state change, or
State.ChangeIntent.NULL if no state
change for the given state occurred. |
int |
intentMask()
For each old->new bit difference, this mask will tell you if the transition was intentional.
|
boolean |
isFor(T_State state)
|
boolean |
isForAll(T_State... states)
|
boolean |
isForAny(T_State... states)
|
int |
newStateBits()
The new and now current bitwise representation of a
BleDevice
or BleManager . |
int |
oldStateBits()
The bitwise representation of the
BleDevice or BleManager
before the event took place. |
protected ChangeEvent(int oldStateBits, int newStateBits, int intentMask)
public int oldStateBits()
BleDevice
or BleManager
before the event took place.public int newStateBits()
BleDevice
or BleManager
. Will be the same as BleDevice.getStateMask()
or BleManager.getStateMask()
.public int intentMask()
BleDevice.disconnect()
in response to a button click, whereas unintentional would be if the device disconnected because it
went out of range. As much as possible these flags are meant to represent the actual app user's intent through the app, not
the intent of you the programmer, nor the intent of the user outside the bounds of the app, like disconnecting by turning the peripheral off.
For example after a disconnect you might be using BleDeviceConfig.reconnectFilter
to try periodically
reconnecting. From you the programmer's perspective a connect, if/when it happens, is arguably an intentional action. From the user's
perspective however the connect was unintentional. Therefore this mask is currently meant to serve an analytics or debugging role,
not to necessarily gate application logic.public int enterMask()
public int exitMask()
public boolean didEnter(T_State state)
State.didEnter(int, int)
.public boolean didExit(T_State state)
State.didExit(int, int)
.public boolean isFor(T_State state)
public boolean isForAny(T_State... states)
public boolean isForAll(T_State... states)
public boolean didEnterAny(T_State... states)
public boolean didExitAny(T_State... states)
public boolean didEnterAll(T_State... states)
public boolean didExitAll(T_State... states)
public State.ChangeIntent getIntent(T_State state)
State.ChangeIntent.NULL
if no state
change for the given state occurred.