當前位置: 首頁>>代碼示例>>Java>>正文


Java Resources.getResourceName方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:24,代碼來源:BlocklyController.java

示例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;
}
 
開發者ID:Mr-wangyong,項目名稱:ImageFrame,代碼行數:26,代碼來源:BitmapLoadUtils.java

示例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;
}
 
開發者ID:ronghao,項目名稱:FrameAnimationView,代碼行數:22,代碼來源:BitmapLoadUtil.java

示例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;
}
 
開發者ID:Zeal27,項目名稱:SkinFramework,代碼行數:17,代碼來源:SkinResource.java

示例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 + "'");
}
 
開發者ID:zxmmmmmm,項目名稱:Mvvm,代碼行數:8,代碼來源:BindingItem.java

示例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;
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:10,代碼來源:Config.java

示例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;

    }
 
開發者ID:XaskYSab,項目名稱:CSkin,代碼行數:27,代碼來源:RecourcesUtil.java


注:本文中的android.content.res.Resources.getResourceName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。