|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.content.res.Resources
android.test.mock.MockResources
public class MockResources
A mock Resources class. All methods are non-functional and throw
UnsupportedOperationException. Override it to provide the operations that you
need.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class android.content.res.Resources |
|---|
Resources.NotFoundException, Resources.Theme |
| Constructor Summary | |
|---|---|
MockResources()
|
|
| Method Summary | |
|---|---|
XmlResourceParser |
getAnimation(int id)
Return an XmlResourceParser through which you can read an animation description for the given resource ID. |
int |
getColor(int id)
Return a color integer associated with a particular resource ID. |
ColorStateList |
getColorStateList(int id)
Return a color state list associated with a particular resource ID. |
Configuration |
getConfiguration()
Return the current configuration that is in effect for this resource object. |
float |
getDimension(int id)
Retrieve a dimensional for a particular resource ID. |
int |
getDimensionPixelOffset(int id)
Retrieve a dimensional for a particular resource ID for use as an offset in raw pixels. |
int |
getDimensionPixelSize(int id)
Retrieve a dimensional for a particular resource ID for use as a size in raw pixels. |
DisplayMetrics |
getDisplayMetrics()
Return the current display metrics that are in effect for this resource object. |
Drawable |
getDrawable(int id)
Return a drawable object associated with a particular resource ID. |
int |
getIdentifier(String name,
String defType,
String defPackage)
Return a resource identifier for the given resource name. |
int[] |
getIntArray(int id)
Return the int array associated with a particular resource ID. |
int |
getInteger(int id)
Return an integer associated with a particular resource ID. |
XmlResourceParser |
getLayout(int id)
Return an XmlResourceParser through which you can read a view layout description for the given resource ID. |
Movie |
getMovie(int id)
Return a movie object associated with the particular resource ID. |
String |
getQuantityString(int id,
int quantity)
Return the string value associated with a particular resource ID for a particular numerical quantity. |
String |
getQuantityString(int id,
int quantity,
Object... formatArgs)
Return the string value associated with a particular resource ID for a particular numerical quantity, substituting the format arguments as defined in Formatter and String.format(java.lang.String, java.lang.Object...). |
CharSequence |
getQuantityText(int id,
int quantity)
|
String |
getResourceEntryName(int resid)
Return the entry name for a given resource identifier. |
String |
getResourceName(int resid)
Return the full name for a given resource identifier. |
String |
getResourcePackageName(int resid)
Return the package name for a given resource identifier. |
String |
getResourceTypeName(int resid)
Return the type name for a given resource identifier. |
String |
getString(int id)
Return the string value associated with a particular resource ID. |
String |
getString(int id,
Object... formatArgs)
Return the string value associated with a particular resource ID, substituting the format arguments as defined in Formatter
and String.format(java.lang.String, java.lang.Object...). |
String[] |
getStringArray(int id)
Return the string array associated with a particular resource ID. |
CharSequence |
getText(int id)
Return the string value associated with a particular resource ID. |
CharSequence |
getText(int id,
CharSequence def)
Return the string value associated with a particular resource ID. |
CharSequence[] |
getTextArray(int id)
Return the styled text array associated with a particular resource ID. |
void |
getValue(int id,
TypedValue outValue,
boolean resolveRefs)
Return the raw data associated with a particular resource ID. |
void |
getValue(String name,
TypedValue outValue,
boolean resolveRefs)
Return the raw data associated with a particular resource ID. |
XmlResourceParser |
getXml(int id)
Return an XmlResourceParser through which you can read a generic XML resource for the given resource ID. |
TypedArray |
obtainAttributes(AttributeSet set,
int[] attrs)
Retrieve a set of basic attribute values from an AttributeSet, not performing styling of them using a theme and/or style resources. |
TypedArray |
obtainTypedArray(int id)
Return an array of heterogeneous values. |
InputStream |
openRawResource(int id)
Open a data stream for reading a raw resource. |
AssetFileDescriptor |
openRawResourceFd(int id)
Open a file descriptor for reading a raw resource. |
void |
updateConfiguration(Configuration config,
DisplayMetrics metrics)
Store the newly updated configuration. |
| Methods inherited from class android.content.res.Resources |
|---|
finishPreloading, flushLayoutCache, getAssets, getSystem, newTheme, startPreloading |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MockResources()
| Method Detail |
|---|
public void updateConfiguration(Configuration config,
DisplayMetrics metrics)
Resources
updateConfiguration in class Resources
public CharSequence getText(int id)
throws Resources.NotFoundException
Resources
getText in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public CharSequence getQuantityText(int id,
int quantity)
throws Resources.NotFoundException
getQuantityText in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public String getString(int id)
throws Resources.NotFoundException
Resources
getString in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public String getString(int id,
Object... formatArgs)
throws Resources.NotFoundException
ResourcesFormatter
and String.format(java.lang.String, java.lang.Object...). It will be stripped of any styled text
information.
getString in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.formatArgs - The format arguments that will be used for substitution.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public String getQuantityString(int id,
int quantity,
Object... formatArgs)
throws Resources.NotFoundException
ResourcesFormatter and String.format(java.lang.String, java.lang.Object...). It will be
stripped of any styled text information.
getQuantityString in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.quantity - The number used to get the correct string for the current language's
plural rules.formatArgs - The format arguments that will be used for substitution.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public String getQuantityString(int id,
int quantity)
throws Resources.NotFoundException
Resources
getQuantityString in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.quantity - The number used to get the correct string for the current language's
plural rules.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public CharSequence getText(int id,
CharSequence def)
Resources
getText in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.def - The default CharSequence to return.
public CharSequence[] getTextArray(int id)
throws Resources.NotFoundException
Resources
getTextArray in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public String[] getStringArray(int id)
throws Resources.NotFoundException
Resources
getStringArray in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public int[] getIntArray(int id)
throws Resources.NotFoundException
Resources
getIntArray in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public TypedArray obtainTypedArray(int id)
throws Resources.NotFoundException
Resources
obtainTypedArray in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
TypedArray.recycle()
when done with it.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public float getDimension(int id)
throws Resources.NotFoundException
ResourcesDisplayMetrics associated
with the resources.
getDimension in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.Resources.getDimensionPixelOffset(int),
Resources.getDimensionPixelSize(int)
public int getDimensionPixelOffset(int id)
throws Resources.NotFoundException
ResourcesResources.getDimension(int), except the returned value is converted to
integer pixels for you. An offset conversion involves simply
truncating the base value to an integer.
getDimensionPixelOffset in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.Resources.getDimension(int),
Resources.getDimensionPixelSize(int)
public int getDimensionPixelSize(int id)
throws Resources.NotFoundException
ResourcesResources.getDimension(int), except the returned value is converted to
integer pixels for use as a size. A size conversion involves
rounding the base value, and ensuring that a non-zero base value
is at least one pixel in size.
getDimensionPixelSize in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.Resources.getDimension(int),
Resources.getDimensionPixelOffset(int)
public Drawable getDrawable(int id)
throws Resources.NotFoundException
Resources
getDrawable in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public Movie getMovie(int id)
throws Resources.NotFoundException
Resources
getMovie in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public int getColor(int id)
throws Resources.NotFoundException
ResourcesColorStateList, then the default color from
the set is returned.
getColor in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public ColorStateList getColorStateList(int id)
throws Resources.NotFoundException
ResourcesColorStateList holding multiple possible colors.
getColorStateList in class Resourcesid - The desired resource identifier of a ColorStateList,
as generated by the aapt tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public int getInteger(int id)
throws Resources.NotFoundException
Resources
getInteger in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public XmlResourceParser getLayout(int id)
throws Resources.NotFoundException
ResourcesThis function is really a simple wrapper for calling
Resources.getXml(int) with a layout resource.
getLayout in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.Resources.getXml(int)
public XmlResourceParser getAnimation(int id)
throws Resources.NotFoundException
ResourcesThis function is really a simple wrapper for calling
Resources.getXml(int) with an animation resource.
getAnimation in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.Resources.getXml(int)
public XmlResourceParser getXml(int id)
throws Resources.NotFoundException
ResourcesThe XmlPullParser implementation returned here has some limited functionality. In particular, you can't change its input, and only high-level parsing events are available (since the document was pre-parsed for you at build time, which involved merging text and stripping comments).
getXml in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.AttributeSet
public InputStream openRawResource(int id)
throws Resources.NotFoundException
Resources
openRawResource in class Resourcesid - The resource identifier to open, as generated by the appt
tool.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public AssetFileDescriptor openRawResourceFd(int id)
throws Resources.NotFoundException
ResourcesThis function only works for resources that are stored in the package as uncompressed data, which typically includes things like mp3 files and png images.
openRawResourceFd in class Resourcesid - The resource identifier to open, as generated by the appt
tool.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public void getValue(int id,
TypedValue outValue,
boolean resolveRefs)
throws Resources.NotFoundException
Resources
getValue in class Resourcesid - The desired resource identifier, as generated by the aapt
tool. This integer encodes the package, type, and resource
entry. The value 0 is an invalid identifier.outValue - Object in which to place the resource data.resolveRefs - If true, a resource that is a reference to another
resource will be followed so that you receive the
actual final resource data. If false, the TypedValue
will be filled in with the reference itself.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public void getValue(String name,
TypedValue outValue,
boolean resolveRefs)
throws Resources.NotFoundException
ResourcesNote: use of this function is discouraged. It is much more efficient to retrieve resources by identifier than by name.
getValue in class Resourcesname - The name of the desired resource. This is passed to
getIdentifier() with a default type of "string".outValue - Object in which to place the resource data.resolveRefs - If true, a resource that is a reference to another
resource will be followed so that you receive the
actual final resource data. If false, the TypedValue
will be filled in with the reference itself.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.
public TypedArray obtainAttributes(AttributeSet set,
int[] attrs)
Resources
obtainAttributes in class Resourcesset - The current attribute values to retrieve.attrs - The specific attributes to be retrieved.
TypedArray.recycle()
when done with it.Resources.Theme.obtainStyledAttributes(AttributeSet, int[], int, int)public DisplayMetrics getDisplayMetrics()
Resources
getDisplayMetrics in class Resourcespublic Configuration getConfiguration()
Resources
getConfiguration in class Resources
public int getIdentifier(String name,
String defType,
String defPackage)
ResourcesNote: use of this function is discouraged. It is much more efficient to retrieve resources by identifier than by name.
getIdentifier in class Resourcesname - The name of the desired resource.defType - Optional default resource type to find, if "type/" is
not included in the name. Can be null to require an
explicit type.defPackage - Optional default package to find, if "package:" is
not included in the name. Can be null to require an
explicit package.
public String getResourceName(int resid)
throws Resources.NotFoundException
Resources
getResourceName in class Resourcesresid - The resource identifier whose name is to be retrieved.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.Resources.getResourcePackageName(int),
Resources.getResourceTypeName(int),
Resources.getResourceEntryName(int)
public String getResourcePackageName(int resid)
throws Resources.NotFoundException
Resources
getResourcePackageName in class Resourcesresid - The resource identifier whose package name is to be
retrieved.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.Resources.getResourceName(int)
public String getResourceTypeName(int resid)
throws Resources.NotFoundException
Resources
getResourceTypeName in class Resourcesresid - The resource identifier whose type name is to be
retrieved.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.Resources.getResourceName(int)
public String getResourceEntryName(int resid)
throws Resources.NotFoundException
Resources
getResourceEntryName in class Resourcesresid - The resource identifier whose entry name is to be
retrieved.
Resources.NotFoundException - Throws NotFoundException if the given ID does not exist.Resources.getResourceName(int)
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||