Package icyllis.modernui.util
Class StateSet
java.lang.Object
icyllis.modernui.util.StateSet
State sets are arrays of positive ints where each element
represents the state of a
View
(e.g. focused,
selected, visible, etc.). A View
may be in
one or more of those states.
A state spec is an array of signed ints where each element
represents a required (if positive) or an undesired (if negative)
View
state.
Utils dealing with state sets.
In theory, we could encapsulate the state set and state spec arrays and not have static methods here but there is some concern about performance since these methods are called during view drawing.
Modified from Android, removes (hardware) accelerated state.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Called by View.static final int
Called by View.static final int
Called by View.static final int
Called by View.static final int
Called by View.static final int
Called by View.static final int
Called by View.static final int
Called by View.static final int
Called by View.static final int[]
A state specification that will be matched by all StateSets. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
containsAttribute
(int[][] stateSpecs, int attr) Check whether a list of state specs has an attribute specified.static int[]
get
(int mask) Called by View.static boolean
isWildCard
(int[] state) Return whether the state is matched by all StateSets.static boolean
stateSetMatches
(int[] stateSpec, int state) Return whether the state matches the desired stateSpec.static boolean
stateSetMatches
(int[] stateSpec, int[] stateSet) Return whether the stateSet matches the desired stateSpec.static int[]
trimStateSet
(int[] states, int newSize)
-
Field Details
-
WILD_CARD
public static final int[] WILD_CARDA state specification that will be matched by all StateSets. -
VIEW_STATE_WINDOW_FOCUSED
public static final int VIEW_STATE_WINDOW_FOCUSEDCalled by View.- See Also:
-
VIEW_STATE_SELECTED
public static final int VIEW_STATE_SELECTEDCalled by View.- See Also:
-
VIEW_STATE_FOCUSED
public static final int VIEW_STATE_FOCUSEDCalled by View.- See Also:
-
VIEW_STATE_ENABLED
public static final int VIEW_STATE_ENABLEDCalled by View.- See Also:
-
VIEW_STATE_PRESSED
public static final int VIEW_STATE_PRESSEDCalled by View.- See Also:
-
VIEW_STATE_ACTIVATED
public static final int VIEW_STATE_ACTIVATEDCalled by View.- See Also:
-
VIEW_STATE_HOVERED
public static final int VIEW_STATE_HOVEREDCalled by View.- See Also:
-
VIEW_STATE_DRAG_CAN_ACCEPT
public static final int VIEW_STATE_DRAG_CAN_ACCEPTCalled by View.- See Also:
-
VIEW_STATE_DRAG_HOVERED
public static final int VIEW_STATE_DRAG_HOVEREDCalled by View.- See Also:
-
-
Method Details
-
get
public static int[] get(int mask) Called by View. -
isWildCard
public static boolean isWildCard(@Nonnull int[] state) Return whether the state is matched by all StateSets.- Parameters:
state
- a state set or state spec.
-
stateSetMatches
public static boolean stateSetMatches(@Nonnull int[] stateSpec, @Nonnull int[] stateSet) Return whether the stateSet matches the desired stateSpec. -
stateSetMatches
public static boolean stateSetMatches(@Nonnull int[] stateSpec, int state) Return whether the state matches the desired stateSpec. -
containsAttribute
public static boolean containsAttribute(@Nonnull int[][] stateSpecs, int attr) Check whether a list of state specs has an attribute specified.- Parameters:
stateSpecs
- a list of state specs we're checking.attr
- an attribute we're looking for.- Returns:
true
if the attribute is contained in the state specs.
-
trimStateSet
@Nonnull public static int[] trimStateSet(@Nonnull int[] states, int newSize)
-