public class ResourceItemResolver
extends com.android.ide.common.rendering.api.RenderResources
ResourceResolver
but for a single item, so it does not need the full resource maps
to be resolved up front. Typically used for cases where we may not have fully configured
resource maps and we need to look up a specific value, such as in Android Studio where
a color reference is found in an XML style file, and we want to resolve it in order to
display the final resolved color in the editor margin.Modifier and Type | Class and Description |
---|---|
static interface |
ResourceItemResolver.ResourceProvider
Interface implemented by clients of the
ResourceItemResolver which allows
it to lazily look up the project resources, the framework resources and optionally
to provide a fully configured resource resolver, if any |
Constructor and Description |
---|
ResourceItemResolver(FolderConfiguration configuration,
ResourceItemResolver.ResourceProvider resourceProvider,
com.android.ide.common.rendering.api.LayoutLog logger) |
ResourceItemResolver(FolderConfiguration configuration,
ResourceRepository frameworkResources,
AbstractResourceRepository appResources,
com.android.ide.common.rendering.api.LayoutLog logger) |
Modifier and Type | Method and Description |
---|---|
com.android.ide.common.rendering.api.ItemResourceValue |
findItemInStyle(com.android.ide.common.rendering.api.StyleResourceValue style,
java.lang.String attrName) |
com.android.ide.common.rendering.api.ItemResourceValue |
findItemInStyle(com.android.ide.common.rendering.api.StyleResourceValue style,
java.lang.String attrName,
boolean isFrameworkAttr) |
com.android.ide.common.rendering.api.ResourceValue |
findItemInTheme(java.lang.String itemName) |
com.android.ide.common.rendering.api.ResourceValue |
findItemInTheme(java.lang.String attrName,
boolean isFrameworkAttr) |
com.android.ide.common.rendering.api.ResourceValue |
findResValue(java.lang.String reference,
boolean inFramework) |
com.android.ide.common.rendering.api.StyleResourceValue |
getCurrentTheme() |
static java.lang.String |
getDisplayString(com.android.resources.ResourceType type,
java.lang.String name,
boolean isFramework,
java.util.List<com.android.ide.common.rendering.api.ResourceValue> lookupChain)
Returns a display string for a resource lookup
|
static java.lang.String |
getDisplayString(java.lang.String url,
java.util.List<com.android.ide.common.rendering.api.ResourceValue> lookupChain)
Returns a display string for a resource lookup
|
java.util.List<com.android.ide.common.rendering.api.ResourceValue> |
getLookupChain()
Returns the lookup chain being used by this resolver
|
com.android.ide.common.rendering.api.StyleResourceValue |
getParent(com.android.ide.common.rendering.api.StyleResourceValue style) |
com.android.ide.common.rendering.api.StyleResourceValue |
getTheme(java.lang.String name,
boolean frameworkTheme) |
com.android.ide.common.rendering.api.ResourceValue |
resolveResValue(com.android.ide.common.rendering.api.ResourceValue resValue) |
com.android.ide.common.rendering.api.ResourceValue |
resolveValue(com.android.resources.ResourceType type,
java.lang.String name,
java.lang.String value,
boolean isFrameworkValue) |
void |
setLookupChainList(java.util.List<com.android.ide.common.rendering.api.ResourceValue> lookupChain)
Optional method to set a list the resolver should record all value resolutions
into.
|
boolean |
themeIsParentOf(com.android.ide.common.rendering.api.StyleResourceValue parentTheme,
com.android.ide.common.rendering.api.StyleResourceValue childTheme) |
public ResourceItemResolver(@NonNull FolderConfiguration configuration, @NonNull ResourceItemResolver.ResourceProvider resourceProvider, @Nullable com.android.ide.common.rendering.api.LayoutLog logger)
public ResourceItemResolver(@NonNull FolderConfiguration configuration, @NonNull ResourceRepository frameworkResources, @NonNull AbstractResourceRepository appResources, @Nullable com.android.ide.common.rendering.api.LayoutLog logger)
@Nullable public com.android.ide.common.rendering.api.ResourceValue resolveResValue(@Nullable com.android.ide.common.rendering.api.ResourceValue resValue)
resolveResValue
in class com.android.ide.common.rendering.api.RenderResources
@Nullable public com.android.ide.common.rendering.api.ResourceValue findResValue(@Nullable java.lang.String reference, boolean inFramework)
findResValue
in class com.android.ide.common.rendering.api.RenderResources
public com.android.ide.common.rendering.api.StyleResourceValue getCurrentTheme()
getCurrentTheme
in class com.android.ide.common.rendering.api.RenderResources
public com.android.ide.common.rendering.api.ResourceValue resolveValue(com.android.resources.ResourceType type, java.lang.String name, java.lang.String value, boolean isFrameworkValue)
resolveValue
in class com.android.ide.common.rendering.api.RenderResources
public com.android.ide.common.rendering.api.StyleResourceValue getTheme(java.lang.String name, boolean frameworkTheme)
getTheme
in class com.android.ide.common.rendering.api.RenderResources
public boolean themeIsParentOf(com.android.ide.common.rendering.api.StyleResourceValue parentTheme, com.android.ide.common.rendering.api.StyleResourceValue childTheme)
themeIsParentOf
in class com.android.ide.common.rendering.api.RenderResources
public com.android.ide.common.rendering.api.ResourceValue findItemInTheme(java.lang.String itemName)
findItemInTheme
in class com.android.ide.common.rendering.api.RenderResources
public com.android.ide.common.rendering.api.ResourceValue findItemInTheme(java.lang.String attrName, boolean isFrameworkAttr)
findItemInTheme
in class com.android.ide.common.rendering.api.RenderResources
public com.android.ide.common.rendering.api.ItemResourceValue findItemInStyle(com.android.ide.common.rendering.api.StyleResourceValue style, java.lang.String attrName)
findItemInStyle
in class com.android.ide.common.rendering.api.RenderResources
public com.android.ide.common.rendering.api.ItemResourceValue findItemInStyle(com.android.ide.common.rendering.api.StyleResourceValue style, java.lang.String attrName, boolean isFrameworkAttr)
findItemInStyle
in class com.android.ide.common.rendering.api.RenderResources
public com.android.ide.common.rendering.api.StyleResourceValue getParent(com.android.ide.common.rendering.api.StyleResourceValue style)
getParent
in class com.android.ide.common.rendering.api.RenderResources
public void setLookupChainList(@Nullable java.util.List<com.android.ide.common.rendering.api.ResourceValue> lookupChain)
@color/buttonForeground ⇒ @color/foreground ⇒ @android:color/black
.
There is no getter. Clients setting this list should look it up themselves. Note also that if this resolver has to delegate to a full resource resolver, e.g. to follow theme attributes, those resolutions will not be recorded.
lookupChain
- the list to set, or null@Nullable public java.util.List<com.android.ide.common.rendering.api.ResourceValue> getLookupChain()
public static java.lang.String getDisplayString(@NonNull com.android.resources.ResourceType type, @NonNull java.lang.String name, boolean isFramework, @NonNull java.util.List<com.android.ide.common.rendering.api.ResourceValue> lookupChain)
type
- the resource typename
- the resource nameisFramework
- whether the item is in the frameworklookupChain
- the list of resolved items to display@NonNull public static java.lang.String getDisplayString(@NonNull java.lang.String url, @NonNull java.util.List<com.android.ide.common.rendering.api.ResourceValue> lookupChain)
url
- the resource url, such as @string/foo
lookupChain
- the list of resolved items to display