public class MagicVariablesArgumentsBundle extends SimpleArgumentsBundle
ArgumentsBundle
that utilizes “magic variables” mechanism to resolve missing
layer arguments: if an argument is not explicitly specified, it tries resolving it from a variable named in a special
pattern @{layer_name}_{arg_name}
where dashes are replaced with underscores.ArgumentsBundle.DimensionUnits, ArgumentsBundle.EdgeAffinity
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
mLayerNamePrefix |
protected java.util.Map<java.lang.String,java.lang.String> |
mVariables |
DIMEN_VALUE_PATTERN, mArguments, mMetrics
UNITS_DP, UNITS_IN, UNITS_MM, UNITS_NULL, UNITS_NUMBER, UNITS_PERCENT, UNITS_PT, UNITS_PX, UNITS_SP
Constructor and Description |
---|
MagicVariablesArgumentsBundle(java.util.Map<java.lang.String,java.lang.String> arguments,
java.util.Map<java.lang.String,java.lang.String> variables,
java.lang.String layerName,
android.util.DisplayMetrics metrics)
Create a new simple arguments bundle implementation from provided key->value map.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
boolean |
hasArgument(java.lang.String key)
Test if there's an argument with given key in the bundle, even if the value is
null . |
int |
hashCode() |
protected java.lang.String |
resolveArgument(java.lang.String key)
Resolves argument value from the bundle.
|
getBoolean, getColor, getDimensionPixelExact, getDimensionPixelOffset, getDimensionPixelRaw, getDimensionPixelSize, getDimensionUnits, getDimensionValue, getDisplayMetrics, getEdgeAffinity, getFloat, getGravity, getInt, getString, getString
protected java.lang.String mLayerNamePrefix
protected java.util.Map<java.lang.String,java.lang.String> mVariables
public MagicVariablesArgumentsBundle(@NonNull java.util.Map<java.lang.String,java.lang.String> arguments, @NonNull java.util.Map<java.lang.String,java.lang.String> variables, java.lang.String layerName, @NonNull android.util.DisplayMetrics metrics)
arguments
- A collection that maps arguments to values. In this implementation both the key and the value
are raw strings, parsed into required data types as requested from the map. The values must be
already provided as parsable literal values — this implementation cannot resolve variables
or calculate expressions.variables
- A @key->value map containing magic variables to fall back tolayerName
- Layer name as registered in the factory, e.g. grid-lines
metrics
- Display metrics associated with this arguments bundle, required so that dimension values (dp,
sppublic boolean hasArgument(java.lang.String key)
null
. If the argument is not declared explicitly, will look up if a matching magic variable is present.hasArgument
in interface ArgumentsBundle
hasArgument
in class SimpleArgumentsBundle
key
- argument keyprotected java.lang.String resolveArgument(java.lang.String key)
@{layer_name}_{arg_name}
(concatenated layer and
argument names with dashes replaced by underscores).resolveArgument
in class SimpleArgumentsBundle
key
- key of the argument whose value to resolvepublic boolean equals(java.lang.Object o)
equals
in class SimpleArgumentsBundle
public int hashCode()
hashCode
in class SimpleArgumentsBundle