Methods Summary |
---|
public final native int | addAssetPath(java.lang.String path)Add an additional set of assets to the asset manager. This can be
either a directory or ZIP file. Not for use by applications. Returns
the cookie of the added asset, or 0 on failure.
{@hide}
|
static final native boolean | applyStyle(int theme, int defStyleAttr, int defStyleRes, int xmlParser, int[] inAttrs, int[] outValues, int[] outIndices)
|
static final native void | applyThemeStyle(int theme, int styleRes, boolean force)
|
public void | close()Close this asset manager.
synchronized(mSync) {
//System.out.println("Release: num=" + mNumRefs
// + ", released=" + mReleased);
if (mOpen) {
mOpen = false;
decRefsLocked();
}
}
|
static final native void | copyTheme(int dest, int source)
|
final int | createTheme()
synchronized (mSync) {
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
mNumRefs++;
return newTheme();
}
|
private final void | decRefsLocked()
/*package*/
/*package*/
/*package*/
/*package*/
/*package*/
/*package*/
/*package*/
/*package*/
/*package*/
mNumRefs--;
//System.out.println("Dec streams: mNumRefs=" + mNumRefs
// + " mReleased=" + mReleased);
if (mNumRefs == 0) {
destroy();
}
|
private final native void | deleteTheme(int theme)
|
private final native void | destroy()
|
private final native void | destroyAsset(int asset)
|
static final native void | dumpTheme(int theme, int priority, java.lang.String tag, java.lang.String prefix)
|
final void | ensureStringBlocks()
if (mStringBlocks == null) {
synchronized (mSync) {
if (mStringBlocks == null) {
makeStringBlocks(true);
}
}
}
|
private static void | ensureSystemAssets()
synchronized (mSync) {
if (mSystem == null) {
AssetManager system = new AssetManager(true);
system.makeStringBlocks(false);
mSystem = system;
}
}
|
protected void | finalize()
destroy();
|
final native int[] | getArrayIntResource(int arrayRes)
|
final native int | getArraySize(int resource)
|
private final native int[] | getArrayStringInfo(int arrayRes)
|
private final native java.lang.String[] | getArrayStringResource(int arrayRes)
|
private final native long | getAssetLength(int asset)
|
private final native long | getAssetRemainingLength(int asset)
|
public final native java.lang.String | getCookieName(int cookie){@hide}
|
public static final native int | getGlobalAssetCount(){@hide}
|
public static final native int | getGlobalAssetManagerCount(){@hide}
|
public final native java.lang.String[] | getLocales()Get the locales that this asset manager contains data for.
|
private final native int | getNativeStringBlock(int block)
|
final java.lang.CharSequence | getPooledString(int block, int id)
//System.out.println("Get pooled: block=" + block
// + ", id=#" + Integer.toHexString(id)
// + ", blocks=" + mStringBlocks);
return mStringBlocks[block-1].get(id);
|
final java.lang.CharSequence | getResourceBagText(int ident, int bagEntryId)Retrieve the string value associated with a particular resource
identifier for the current configuration / skin.
synchronized (mSync) {
TypedValue tmpValue = mValue;
int block = loadResourceBagValue(ident, bagEntryId, tmpValue, true);
if (block >= 0) {
if (tmpValue.type == TypedValue.TYPE_STRING) {
return mStringBlocks[block].get(tmpValue.data);
}
return tmpValue.coerceToString();
}
}
return null;
|
final native java.lang.String | getResourceEntryName(int resid)
|
final native int | getResourceIdentifier(java.lang.String type, java.lang.String name, java.lang.String defPackage)Retrieve the resource identifier for the given resource name.
|
final native java.lang.String | getResourceName(int resid)
|
final native java.lang.String | getResourcePackageName(int resid)
|
final java.lang.String[] | getResourceStringArray(int id)Retrieve the string array associated with a particular resource
identifier.
String[] retArray = getArrayStringResource(id);
return retArray;
|
final java.lang.CharSequence | getResourceText(int ident)Retrieve the string value associated with a particular resource
identifier for the current configuration / skin.
synchronized (mSync) {
TypedValue tmpValue = mValue;
int block = loadResourceValue(ident, tmpValue, true);
if (block >= 0) {
if (tmpValue.type == TypedValue.TYPE_STRING) {
return mStringBlocks[block].get(tmpValue.data);
}
return tmpValue.coerceToString();
}
}
return null;
|
final java.lang.CharSequence[] | getResourceTextArray(int id)Retrieve the text array associated with a particular resource
identifier.
int[] rawInfoArray = getArrayStringInfo(id);
int rawInfoArrayLen = rawInfoArray.length;
final int infoArrayLen = rawInfoArrayLen / 2;
int block;
int index;
CharSequence[] retArray = new CharSequence[infoArrayLen];
for (int i = 0, j = 0; i < rawInfoArrayLen; i = i + 2, j++) {
block = rawInfoArray[i];
index = rawInfoArray[i + 1];
retArray[j] = index >= 0 ? mStringBlocks[block].get(index) : null;
}
return retArray;
|
final native java.lang.String | getResourceTypeName(int resid)
|
final boolean | getResourceValue(int ident, android.util.TypedValue outValue, boolean resolveRefs)
int block = loadResourceValue(ident, outValue, resolveRefs);
if (block >= 0) {
if (outValue.type != TypedValue.TYPE_STRING) {
return true;
}
outValue.string = mStringBlocks[block].get(outValue.data);
return true;
}
return false;
|
private final native int | getStringBlockCount()
|
public static android.content.res.AssetManager | getSystem()Return a global shared asset manager that provides access to only
system assets (no application assets).
{@hide}
ensureSystemAssets();
return mSystem;
|
final boolean | getThemeValue(int theme, int ident, android.util.TypedValue outValue, boolean resolveRefs)
int block = loadThemeAttributeValue(theme, ident, outValue, resolveRefs);
if (block >= 0) {
if (outValue.type != TypedValue.TYPE_STRING) {
return true;
}
StringBlock[] blocks = mStringBlocks;
if (blocks == null) {
ensureStringBlocks();
}
outValue.string = blocks[block].get(outValue.data);
return true;
}
return false;
|
private final native void | init()
|
public final native boolean | isUpToDate()Determine whether the state in this asset manager is up-to-date with
the files on the filesystem. If false is returned, you need to
instantiate a new AssetManager class to see the new data.
{@hide}
|
public final native java.lang.String[] | list(java.lang.String path)Return a String array of all the assets at the given path.
|
private final native int | loadResourceBagValue(int ident, int bagEntryId, android.util.TypedValue outValue, boolean resolve)Returns true if the resource was found, filling in mRetStringBlock and
mRetData.
|
private final native int | loadResourceValue(int ident, android.util.TypedValue outValue, boolean resolve)Returns true if the resource was found, filling in mRetStringBlock and
mRetData.
|
static final native int | loadThemeAttributeValue(int theme, int ident, android.util.TypedValue outValue, boolean resolve)
|
private final void | makeStringBlocks(boolean copyFromSystem)
final int sysNum = copyFromSystem ? mSystem.mStringBlocks.length : 0;
final int num = getStringBlockCount();
mStringBlocks = new StringBlock[num];
if (localLOGV) Log.v(TAG, "Making string blocks for " + this
+ ": " + num);
for (int i=0; i<num; i++) {
if (i < sysNum) {
mStringBlocks[i] = mSystem.mStringBlocks[i];
} else {
mStringBlocks[i] = new StringBlock(getNativeStringBlock(i), true);
}
}
|
private final native int | newTheme()
|
public final java.io.InputStream | open(java.lang.String fileName)Open an asset using ACCESS_STREAMING mode. This provides access to
files that have been bundled with an application as assets -- that is,
files placed in to the "assets" directory.
return open(fileName, ACCESS_STREAMING);
|
public final java.io.InputStream | open(java.lang.String fileName, int accessMode)Open an asset using an explicit access mode, returning an InputStream to
read its contents. This provides access to files that have been bundled
with an application as assets -- that is, files placed in to the
"assets" directory.
synchronized (mSync) {
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
int asset = openAsset(fileName, accessMode);
if (asset != 0) {
mNumRefs++;
return new AssetInputStream(asset);
}
}
throw new FileNotFoundException("Asset file: " + fileName);
|
private final native int | openAsset(java.lang.String fileName, int accessMode)
|
private final native android.os.ParcelFileDescriptor | openAssetFd(java.lang.String fileName, long[] outOffsets)
|
public final AssetFileDescriptor | openFd(java.lang.String fileName)
synchronized (mSync) {
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
ParcelFileDescriptor pfd = openAssetFd(fileName, mOffsets);
if (pfd != null) {
return new AssetFileDescriptor(pfd, mOffsets[0], mOffsets[1]);
}
}
throw new FileNotFoundException("Asset file: " + fileName);
|
public final java.io.InputStream | openNonAsset(java.lang.String fileName){@hide}
Open a non-asset file as an asset using ACCESS_STREAMING mode. This
provides direct access to all of the files included in an application
package (not only its assets). Applications should not normally use
this.
return openNonAsset(0, fileName, ACCESS_STREAMING);
|
public final java.io.InputStream | openNonAsset(java.lang.String fileName, int accessMode){@hide}
Open a non-asset file as an asset using a specific access mode. This
provides direct access to all of the files included in an application
package (not only its assets). Applications should not normally use
this.
return openNonAsset(0, fileName, accessMode);
|
public final java.io.InputStream | openNonAsset(int cookie, java.lang.String fileName){@hide}
Open a non-asset in a specified package. Not for use by applications.
return openNonAsset(cookie, fileName, ACCESS_STREAMING);
|
public final java.io.InputStream | openNonAsset(int cookie, java.lang.String fileName, int accessMode){@hide}
Open a non-asset in a specified package. Not for use by applications.
synchronized (mSync) {
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
int asset = openNonAssetNative(cookie, fileName, accessMode);
if (asset != 0) {
mNumRefs++;
return new AssetInputStream(asset);
}
}
throw new FileNotFoundException("Asset absolute file: " + fileName);
|
public final AssetFileDescriptor | openNonAssetFd(java.lang.String fileName)
return openNonAssetFd(0, fileName);
|
public final AssetFileDescriptor | openNonAssetFd(int cookie, java.lang.String fileName)
synchronized (mSync) {
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
ParcelFileDescriptor pfd = openNonAssetFdNative(cookie,
fileName, mOffsets);
if (pfd != null) {
return new AssetFileDescriptor(pfd, mOffsets[0], mOffsets[1]);
}
}
throw new FileNotFoundException("Asset absolute file: " + fileName);
|
private native android.os.ParcelFileDescriptor | openNonAssetFdNative(int cookie, java.lang.String fileName, long[] outOffsets)
|
private final native int | openNonAssetNative(int cookie, java.lang.String fileName, int accessMode)
|
private final native int | openXmlAssetNative(int cookie, java.lang.String fileName)
|
final XmlBlock | openXmlBlockAsset(java.lang.String fileName){@hide}
Retrieve a non-asset as a compiled XML file. Not for use by
applications.
return openXmlBlockAsset(0, fileName);
|
final XmlBlock | openXmlBlockAsset(int cookie, java.lang.String fileName){@hide}
Retrieve a non-asset as a compiled XML file. Not for use by
applications.
synchronized (mSync) {
if (!mOpen) {
throw new RuntimeException("Assetmanager has been closed");
}
int xmlBlock = openXmlAssetNative(cookie, fileName);
if (xmlBlock != 0) {
mNumRefs++;
return new XmlBlock(this, xmlBlock);
}
}
throw new FileNotFoundException("Asset XML file: " + fileName);
|
public final XmlResourceParser | openXmlResourceParser(java.lang.String fileName)Retrieve a parser for a compiled XML file.
return openXmlResourceParser(0, fileName);
|
public final XmlResourceParser | openXmlResourceParser(int cookie, java.lang.String fileName)Retrieve a parser for a compiled XML file.
XmlBlock block = openXmlBlockAsset(cookie, fileName);
XmlResourceParser rp = block.newParser();
block.close();
return rp;
|
private final native int | readAsset(int asset, byte[] b, int off, int len)
|
private final native int | readAssetChar(int asset)
|
final void | releaseTheme(int theme)
synchronized (mSync) {
deleteTheme(theme);
decRefsLocked();
}
|
final native int | retrieveArray(int resource, int[] outValues)
|
final native boolean | retrieveAttributes(int xmlParser, int[] inAttrs, int[] outValues, int[] outIndices)
|
private final native long | seekAsset(int asset, long offset, int whence)
|
public final native void | setConfiguration(int mcc, int mnc, java.lang.String locale, int orientation, int touchscreen, int density, int keyboard, int keyboardHidden, int navigation, int screenWidth, int screenHeight, int majorVersion)Change the configuation used when retrieving resources. Not for use by
applications.
{@hide}
|
public final native void | setLocale(java.lang.String locale)Change the locale being used by this asset manager. Not for use by
applications.
{@hide}
|
void | xmlBlockGone()
synchronized (mSync) {
decRefsLocked();
}
|