java.lang.Object | |
↳ | com.neomades.app.ResManager |
Resource Manager.
To use the resource manager into application screens, you could call
ResManager
methods.
public class MyScreen extends Screen { protected void onCreate() { // return the text contained into the project csv ResManager.getString(Res.string.ID_OF_THE_TEXT); } }
Note: Do not call ResManager in any static initializer.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static void |
clearImageCache()
Clear the image cache.
| ||||||||||
static Background |
getBackground(int backgroundResId)
Gets a XML background resource.
| ||||||||||
static boolean |
getBool(int booleanResId)
Gets a XML boolean resource.
| ||||||||||
static Color |
getColor(int colorResId)
Gets a XML color resource.
| ||||||||||
static int |
getDimen(int dimenResId)
Gets a XML dimen resource.
| ||||||||||
static Font |
getFont(int resId)
Loads a TTF font from resources, with the platform's default font size.
| ||||||||||
static Font |
getFont(int resId, int size)
Loads a TTF font from resources and specify in parameter the size
(height) of the font.
| ||||||||||
static Image |
getImage(int resId)
Gets an image from a resource identifier.
| ||||||||||
static int |
getInteger(int integerResId)
Gets a XML integer resource.
| ||||||||||
static View |
getLayout(int layoutResId)
Gets a XML Layout resource.
| ||||||||||
static byte[] |
getRawData(int resId)
Gets a raw data resource.
| ||||||||||
static InputStream |
getResourceAsStream(String path)
Finds a resource with a given name.
| ||||||||||
static Sound |
getSound(int resId)
Gets a sound from a resource identifier.
| ||||||||||
static String |
getString(int resId, Object... formatArgs)
Gets a localized string from a resource identifier.
| ||||||||||
static Style |
getStyle(int styleResId)
Gets a XML style resource.
| ||||||||||
static InputStream |
openAsset(String assetPath)
Opens a resource stream from assets folder.
| ||||||||||
static InputStream |
openRaw(int resId)
Opens a raw resource as stream.
| ||||||||||
static void |
setImageCacheEnabled(boolean enabled)
By default, the image cache is enabled in iOS.
| ||||||||||
static void |
setLanguage(int languageID)
Sets the language for multi-languages binaries.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Gets a XML background resource.
backgroundResId | resource identifier from Res.background |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Gets a XML boolean resource.
booleanResId | resource identifier from Res.bool |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Gets a XML color resource.
colorResId | resource identifier from Res.color |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Gets a XML dimen resource.
dimenResId | resource identifier from Res.dimen |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Loads a TTF font from resources, with the platform's default font size.
See <font> declaration in the URS file.
For the iOS platform, bold and italic fonts must be provided in order to be able to use a TTF font with these styles. In other platforms the system will apply the style on the TTF font even if the related TTF files are not provided.
resId | resource identifier from Res.font |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found or cannot be loaded |
---|
Loads a TTF font from resources and specify in parameter the size (height) of the font.
See <font> declaration in the URS file.
resId | resource identifier from Res.font |
---|---|
size | size of the font |
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found or cannot be loaded |
---|
Gets an image from a resource identifier. The identifier is given in the class Resources, generated by NeoMAD.
ResManager
uses a cache of loaded images.
See <image> declaration in the URS file.
resId | resource identifier from Res.image |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Gets a XML integer resource.
integerResId | resource identifier from Res.integer |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Gets a XML Layout resource.
layoutResId | resource identifier from Res.layout |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Gets a raw data resource.
resId | resource identifier from Res.raw |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Finds a resource with a given name. This method returns null if no resource with this name is found.
Replace the Class method : getResourceAsStream(String)
.
This method could be used to load a resource declared as <jarfiles> in the URS.
EG. a jar file declared with the path "./folder/file.txt" can be loaded using this method setting the path "folder/file.txt" in parameter.
path | the resource path from the binary |
---|
Gets a sound from a resource identifier. The identifier is given in the class Resources, generated by NeoMAD.
See <sound> declaration in the URS file.
resId | resource identifier from Res.music |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Gets a localized string from a resource identifier. See documentation for more details about how to declare string resources.
If this method is invoked with format arguments, the string resource is
formatted using the StringUtils#format(String, Object[]) method. See
java.util.Formatter
for a list of valid format specifiers that
can be used. If no format arguments are given during the invocation, the
exact string resource is returned.
Note: If a string resource is not available for the device's current locale (it is not declared in the corresponding XML file), the name of the resource is returned.
resId | resource identifier from Res.string |
---|---|
formatArgs | arguments used to format the string resource |
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Gets a XML style resource.
styleResId | resource identifier from Res.style |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
Opens a resource stream from assets folder.
assetPath | relative path from assets folder |
---|
ResourceNotFoundException | when the resource corresponding to the assetPath parameter was not found |
---|
Opens a raw resource as stream.
resId | resource identifier from Res.raw |
---|
ResourceNotFoundException | when the resource corresponding to the resId parameter was not found |
---|
By default, the image cache is enabled in iOS. The image cache is cleared between each creation of screens.
enabled | true to enable cache |
---|
Sets the language for multi-languages binaries.
languageID | language identifier from Res.lang
|
---|