Package org.robolectric.shadows
Class ShadowResources
- java.lang.Object
-
- org.robolectric.shadows.ShadowResources
-
@Implements(android.content.res.Resources.class) public class ShadowResources extends Object
Shadow ofResources.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShadowResources.ShadowLegacyThemeShadow forResources.Theme.static classShadowResources.ShadowNotFoundExceptionShadow forResources.NotFoundException.static classShadowResources.ShadowThemeBase class for shadows ofResources.Theme.
-
Constructor Summary
Constructors Constructor Description ShadowResources()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intgetAttributeSetSourceResId(AttributeSet attrs)Returns the layout resource id the attribute set was inflated from.protected StringgetQuantityString(int resId, int quantity)protected StringgetQuantityString(int id, int quantity, Object... formatArgs)protected static ResourcesgetSystem()protected DrawableloadDrawable(TypedValue value, int id)protected DrawableloadDrawable(TypedValue value, int id, Resources.Theme theme)protected XmlResourceParserloadXmlResourceParser(int resId, String type)protected XmlResourceParserloadXmlResourceParser(String file, int id, int assetCookie, String type)protected TypedArrayobtainAttributes(AttributeSet set, int[] attrs)protected TypedArrayobtainTypedArray(int id)protected InputStreamopenRawResource(int id)protected AssetFileDescriptoropenRawResourceFd(int id)SinceAssetFileDescriptors are not yet supported by Robolectric,nullwill be returned if the resource is found.static voidreset()
-
-
-
Method Detail
-
reset
@Resetter public static void reset()
-
getSystem
@Implementation protected static Resources getSystem()
-
obtainAttributes
@Implementation protected TypedArray obtainAttributes(AttributeSet set, int[] attrs)
-
getQuantityString
@Implementation protected String getQuantityString(int id, int quantity, Object... formatArgs) throws Resources.NotFoundException
- Throws:
Resources.NotFoundException
-
getQuantityString
@Implementation protected String getQuantityString(int resId, int quantity) throws Resources.NotFoundException
- Throws:
Resources.NotFoundException
-
openRawResource
@Implementation protected InputStream openRawResource(int id) throws Resources.NotFoundException
- Throws:
Resources.NotFoundException
-
openRawResourceFd
@Implementation protected AssetFileDescriptor openRawResourceFd(int id) throws Resources.NotFoundException
SinceAssetFileDescriptors are not yet supported by Robolectric,nullwill be returned if the resource is found. If the resource cannot be found,Resources.NotFoundExceptionwill be thrown.- Throws:
Resources.NotFoundException
-
obtainTypedArray
@Implementation protected TypedArray obtainTypedArray(int id) throws Resources.NotFoundException
- Throws:
Resources.NotFoundException
-
loadXmlResourceParser
@HiddenApi @Implementation protected XmlResourceParser loadXmlResourceParser(int resId, String type) throws Resources.NotFoundException
- Throws:
Resources.NotFoundException
-
loadXmlResourceParser
@HiddenApi @Implementation protected XmlResourceParser loadXmlResourceParser(String file, int id, int assetCookie, String type) throws Resources.NotFoundException
- Throws:
Resources.NotFoundException
-
loadDrawable
@HiddenApi @Implementation(maxSdk=20) protected Drawable loadDrawable(TypedValue value, int id)
-
loadDrawable
@Implementation(minSdk=21, maxSdk=25) protected Drawable loadDrawable(TypedValue value, int id, Resources.Theme theme) throws Resources.NotFoundException
- Throws:
Resources.NotFoundException
-
getAttributeSetSourceResId
@Implementation(minSdk=29) public static int getAttributeSetSourceResId(AttributeSet attrs)
Returns the layout resource id the attribute set was inflated from. Backwards compatible version ofResources.getAttributeSetSourceResId(AttributeSet), passes through to the underlying implementation on API levels where it is supported.
-
-