本文整理匯總了Java中android.content.res.Resources.getResourceName方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getResourceName方法的具體用法?Java Resources.getResourceName怎麽用?Java Resources.getResourceName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.Resources
的用法示例。
在下文中一共展示了Resources.getResourceName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadBlockDefinitionsFromResources
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Loads list of block definitions from resources or fail with IllegalStateException.
*
* @param factory The factory to add block definitions to.
* @param resIds The resource ids to raw XML files with the block definitions.
*/
private void loadBlockDefinitionsFromResources(BlockFactory factory, List<Integer> resIds) {
Resources resources = mContext.getResources();
for (int i = 0; i < resIds.size(); i++) {
int resourceId = resIds.get(i);
try {
InputStream is = resources.openRawResource(resourceId);
factory.addJsonDefinitions(is);
} catch (IOException | BlockLoadingException e) {
factory.clear(); // Clear partially loaded resources.
// Compile-time bundled assets are assumed to always be valid.
String resName = resources.getResourceName(resourceId);
throw new IllegalStateException(
"Failed to load block definition from resource id " + resourceId
+ (resName == null ? "" : " \"" + resName + "\""), e);
}
}
}
示例2: decodeSampledBitmapFromRes
import android.content.res.Resources; //導入方法依賴的package包/類
static BitmapDrawable decodeSampledBitmapFromRes(Resources resources, @RawRes int resId,
int reqWidth, int reqHeight,
ImageCache cache, boolean isOpenLruCache) {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
decodeStream(resources.openRawResource(resId), null, options);
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// String resourceName = resources.getResourceName(resId);
// if (Utils.hasHoneycomb()) {
BitmapDrawable bitmapFromCache;
if (isOpenLruCache) {
String resourceName = resources.getResourceName(resId);
bitmapFromCache = cache.getBitmapFromCache(resourceName);
if (bitmapFromCache == null) {
// if (Utils.hasHoneycomb()) {
bitmapFromCache = readBitmapFromRes(resources, resId, cache, options);
cache.addBitmap(resourceName, bitmapFromCache);
}
} else {
bitmapFromCache = readBitmapFromRes(resources, resId, cache, options);
}
return bitmapFromCache;
}
示例3: decodeBitmapFromResLruCache
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* 讀取圖片 優先從緩存中獲取圖片
*/
static BitmapDrawable decodeBitmapFromResLruCache(Resources resources, @RawRes int resId,
int reqWidth, int reqHeight,
ImageCache cache) {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
decodeStream(resources.openRawResource(resId), null, options);
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
BitmapDrawable bitmapFromCache;
String resourceName = resources.getResourceName(resId);
bitmapFromCache = cache.getBitmapFromCache(resourceName);
if (bitmapFromCache == null) {
bitmapFromCache = readBitmapFromRes(resources, resId, cache, options);
cache.addBitmapToCache(resourceName, bitmapFromCache);
}
return bitmapFromCache;
}
示例4: getCorrespondResId
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Get correspond resource id in skin archive.
*
* @param resId Resource id in app.
* @return 0 if not exist
*/
public int getCorrespondResId(int resId) {
Resources appResources = getAppResources();
String resName = appResources.getResourceName(resId);
if (!TextUtils.isEmpty(resName)) {
String skinName = resName.replace(mAppPackageName, getPackageName());
int id = getIdentifier(skinName, null, null);
return id;
}
return 0;
}
示例5: throwMissingVariable
import android.content.res.Resources; //導入方法依賴的package包/類
private static void throwMissingVariable(ViewDataBinding binding, int bindingVariable, @LayoutRes int layoutRes) {
Context context = binding.getRoot().getContext();
Resources resources = context.getResources();
String layoutName = resources.getResourceName(layoutRes);
String bindingVariableName = DataBindingUtil.convertBrIdToString(bindingVariable);
throw new IllegalStateException("Could not bind variable '" + bindingVariableName + "' in layout '" + layoutName + "'");
}
示例6: activityTheme
import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public Config activityTheme(@StyleRes int theme) {
final Resources r = mContext.getResources();
final String name = r.getResourceName(theme);
final String defType = r.getResourceTypeName(theme);
mEditor.putString(KEY_ACTIVITY_THEME, name);
mEditor.putString(KEY_ACTIVITY_THEME_DEFTYPE, defType);
return this;
}
示例7: getPluginResourceId
import android.content.res.Resources; //導入方法依賴的package包/類
public static int getPluginResourceId(Context context, String apkPath, int oldResourceId) {
Resources resources = context.getResources();
String colorName = resources.getResourceName(oldResourceId);
String entryName = resources.getResourceEntryName(oldResourceId);
String typeName = resources.getResourceTypeName(oldResourceId);
Log.e("MyLog", colorName + "," + entryName + "," + typeName);
Resources pluginResources = resourcesMap.get(apkPath);
if (pluginResources == null) {
pluginResources = RecourcesUtil.getResources(context, apkPath);
resourcesMap.put(apkPath, pluginResources);
}
String packageName = SPluginUtil.getPackageInfo(context, apkPath).packageName;
int colorId = pluginResources.getIdentifier(entryName, typeName, packageName);
Log.e("MyLog", colorId + "");
return colorId;
}