Methods Summary |
---|
public com.android.resources.Density | getDensity()Should only be called after {@link #getIcon()}. Returns the density of the icon, if found by
{@code getIcon()}. If no icon was found, then the return value has no meaning.
return mCurrentDensity;
|
public java.io.InputStream | getIcon()
for (String resourceDir : Config.getResourceDirs(mPlatformVersion)) {
mCurrentDensity = null;
InputStream stream = getIcon(resourceDir);
if (stream != null) {
return stream;
}
}
return null;
|
private java.io.InputStream | getIcon(java.lang.String resourceDir)Search for icon in the resource directory. This iterates over all densities.
If a match is found, mCurrentDensity will be set to the icon's density.
// First check for the desired density.
InputStream stream = getIcon(resourceDir, mDesiredDensity);
if (stream != null) {
mCurrentDensity = mDesiredDensity;
return stream;
}
// Didn't find in the desired density. Search in all.
for (Density density : Density.values()) {
if (density == mDesiredDensity) {
// Skip the desired density since it's already been checked.
continue;
}
stream = getIcon(resourceDir, density);
if (stream != null) {
mCurrentDensity = density;
return stream;
}
}
return null;
|
private java.io.InputStream | getIcon(java.lang.String resourceDir, com.android.resources.Density density)Returns the icon for given density present in the given resource directory, taking layout
direction into consideration.
mCurrentPath.setLength(0);
// Currently we don't have any LTR only resources and hence the check is skipped. If they
// are ever added, change to:
// if (mDirection == LayoutDirection.RTL || mDirection == LayoutDirection.LTR) {
if (mDirection == LayoutDirection.RTL) {
mCurrentPath.append(resourceDir)
.append(mDirection.getResourceValue())
.append('-")
.append(density.getResourceValue())
.append('/")
.append(mIconName);
InputStream stream = getClass().getResourceAsStream(mCurrentPath.toString());
if (stream != null) {
return stream;
}
mCurrentPath.setLength(0);
}
mCurrentPath.append(resourceDir)
.append(density.getResourceValue())
.append('/")
.append(mIconName);
return getClass().getResourceAsStream(mCurrentPath.toString());
|
public java.lang.String | getPath()Should only be called after {@link #getIcon()}. Returns the path to the icon, if found by
{@code getIcon()}. If no icon was found, then the return value has no meaning.
return mCurrentPath.toString();
|