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


Java Resources.getResourceEntryName方法代碼示例

本文整理匯總了Java中android.content.res.Resources.getResourceEntryName方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getResourceEntryName方法的具體用法?Java Resources.getResourceEntryName怎麽用?Java Resources.getResourceEntryName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.getResourceEntryName方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: inflate

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public View inflate(int resourceId, ViewGroup root, boolean attachToRoot) {
    final Resources res = getContext().getResources();
    final String packageName = res.getResourcePackageName(resourceId);
    final String resName = res.getResourceEntryName(resourceId);
    final View view = original.inflate(resourceId, root, attachToRoot);

    if (!appPackageName.equals(packageName)) {
        return view;
    }

    View targetView = view;
    if (root != null && attachToRoot) {
        targetView = root.getChildAt(root.getChildCount() - 1);
    }

    targetView.setTag(TAG_RES_NAME, resName);

    return view;
}
 
開發者ID:nekocode,項目名稱:ResourceInspector,代碼行數:21,代碼來源:ResourceInspector.java

示例2: matchesSafely

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
protected boolean matchesSafely(View target) {
    if (!(target instanceof ImageView)) {
        return false;
    }
    ImageView imageView = (ImageView) target;
    if (expectedId == EMPTY) {
        return imageView.getDrawable() == null;
    }
    if (expectedId == ANY) {
        return imageView.getDrawable() != null;
    }
    Resources resources = target.getContext().getResources();
    Drawable expectedDrawable = resources.getDrawable(expectedId);
    resourceName = resources.getResourceEntryName(expectedId);

    if (expectedDrawable == null) {
        return false;
    }

    Bitmap bitmap = getBitmap(imageView.getDrawable());
    Bitmap otherBitmap = getBitmap(expectedDrawable);
    return bitmap.sameAs(otherBitmap);
}
 
開發者ID:erdo,項目名稱:asaf-project,代碼行數:25,代碼來源:DrawableMatcher.java

示例3: parseHotKeys

import android.content.res.Resources; //導入方法依賴的package包/類
private static HotKeySet parseHotKeys(
        @Nonnull final Resources resources, final int resourceId) {
    final HotKeySet keySet = new HotKeySet();
    final String name = resources.getResourceEntryName(resourceId);
    final String[] values = resources.getStringArray(resourceId);
    for (int i = 0; values != null && i < values.length; i++) {
        String[] valuePair = values[i].split(",");
        if (valuePair.length != 2) {
            Log.w(TAG, "Expected 2 integers in " + name + "[" + i + "] : " + values[i]);
        }
        try {
            final Integer keyCode = Integer.parseInt(valuePair[0]);
            final Integer metaState = Integer.parseInt(valuePair[1]);
            final Pair<Integer, Integer> key = Pair.create(
                    keyCode, KeyEvent.normalizeMetaState(metaState));
            keySet.add(key);
        } catch (NumberFormatException e) {
            Log.w(TAG, "Failed to parse " + name + "[" + i + "] : " + values[i], e);
        }
    }
    return keySet;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:23,代碼來源:EmojiAltPhysicalKeyDetector.java

示例4: getViewSign

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * 獲取View的簽名
 *
 * @param view
 * @return
 */
public static String getViewSign(View view) {
    StringBuilder sign = new StringBuilder(128);
    sign.append(view.getClass().getName());
    sign.append('{');
    sign.append(Integer.toHexString(System.identityHashCode(view)));
    sign.append(' ');
    sign.append(view.getLeft());
    sign.append(',');
    sign.append(view.getTop());
    sign.append('-');
    sign.append(view.getRight());
    sign.append(',');
    sign.append(view.getBottom());
    final int id = view.getId();
    if (id != View.NO_ID) {
        sign.append(" #");
        sign.append(Integer.toHexString(id));
        final Resources r = view.getResources();
        if (id > 0 && resourceHasPackage(id) && r != null) {
            try {
                String pkgname;
                switch (id & 0xff000000) {
                    case 0x7f000000:
                        pkgname = "app";
                        break;
                    case 0x01000000:
                        pkgname = "android";
                        break;
                    default:
                        pkgname = r.getResourcePackageName(id);
                        break;
                }
                String typename = r.getResourceTypeName(id);
                String entryname = r.getResourceEntryName(id);
                sign.append(" ");
                sign.append(pkgname);
                sign.append(":");
                sign.append(typename);
                sign.append("/");
                sign.append(entryname);
                if ("android".equals(pkgname) && "id".equals(typename) && "content".equals(entryname)) {
                    //找到android:id/content的父View,認為是根View了,不再查找
                    isRootParent = true;
                }
            } catch (Resources.NotFoundException e) {
            }
        }
    }
    sign.append('}');
    return sign.toString();
}
 
開發者ID:zkwlx,項目名稱:DroidTelescope,代碼行數:58,代碼來源:ViewUtils.java

示例5: getNameByResourceId

import android.content.res.Resources; //導入方法依賴的package包/類
private static String getNameByResourceId(int id) {
    long t1 = System.currentTimeMillis();
    String viewName = "";
    try {
        Resources r = GlobalsContext.mApplication.getResources();
        viewName = r.getResourceEntryName(id);
    } catch (Throwable th) {
        TrackerLog.d("getNameByResourceId fail " + th.getMessage());
    }
    TrackerLog.d("getNameByResourceId, costTime=" + (System.currentTimeMillis() - t1));
    TrackerLog.d("getNameByResourceId, viewName=" + viewName);
    return viewName;
}
 
開發者ID:alibaba,項目名稱:android_viewtracker,代碼行數:14,代碼來源:TrackerUtil.java

示例6: getAssetsNamesFromLayoutIds

import android.content.res.Resources; //導入方法依賴的package包/類
private static String[] getAssetsNamesFromLayoutIds(Context context, String resLayoutAssets, @AnyRes int... ids){
    final Resources resources = context.getResources();
    final int size = ids.length;
    final String[] assetNames = new String[size];
    for (int i = 0; i < size; i++) {
        final int id = ids[i];

        final String resourceEntryName = resources.getResourceEntryName(id);

        assetNames[i] = resLayoutAssets + "/" + resourceEntryName + ".xml.txt";
    }

    return assetNames;
}
 
開發者ID:ABTSoftware,項目名稱:SciChart.Android.Examples,代碼行數:15,代碼來源:ZipAndShareTask.java

示例7: generateResourceNameFromId

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Generates a Resource name from resourceId located in res/ folder.
 *
 * @param resourceId id of the resource, must be greater then 0.
 * @return resourceName in format folder/file.extension.
 */
public static String generateResourceNameFromId(int resourceId) {
  try {
    if (resourceId <= 0) {
      Log.w("Provided resource id is invalid.");
      return null;
    }
    Resources resources = Leanplum.getContext().getResources();
    // Get entryName from resourceId, which represents a file name in res/ directory.
    String entryName = resources.getResourceEntryName(resourceId);
    // Get typeName from resourceId, which represents a folder where file is located in
    // res/ directory.
    String typeName = resources.getResourceTypeName(resourceId);

    // By using TypedValue we can get full path of a file with extension.
    TypedValue value = new TypedValue();
    resources.getValue(resourceId, value, true);

    // Regex matching to find real file extension, "image.img.png" will produce "png".
    String[] fullFileName = value.string.toString().split("\\.(?=[^\\.]+$)");
    String extension = "";
    // If extension is found, we will append dot before it.
    if (fullFileName.length == 2) {
      extension = "." + fullFileName[1];
    }

    // Return full resource name in format: drawable/image.png
    return typeName + "/" + entryName + extension;
  } catch (Exception e) {
    Log.w("Failed to generate resource name from provided resource id: ", e);
    Util.handleException(e);
  }
  return null;
}
 
開發者ID:Leanplum,項目名稱:Leanplum-Android-SDK,代碼行數:40,代碼來源:Util.java

示例8: getUriFromDrawableRes

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * 得到資源文件中圖片的Uri
 * @param context 上下文對象
 * @param id 資源id
 * @return Uri
 */
public static Uri getUriFromDrawableRes(Context context, int id) {
	Resources resources = context.getResources();
	String path = ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
			+ resources.getResourcePackageName(id) + "/"
			+ resources.getResourceTypeName(id) + "/"
			+ resources.getResourceEntryName(id);
	return Uri.parse(path);
}
 
開發者ID:ebridfighter,項目名稱:GongXianSheng,代碼行數:15,代碼來源:CommonUtils.java

示例9: getDimen

import android.content.res.Resources; //導入方法依賴的package包/類
private int getDimen(int resId) {
    int dimen = (int) getResources().getDimension(resId);
    if (SkinCompatResources.getInstance().isDefaultSkin()) {
        return dimen;
    }

    Resources res = SkinCompatResources.getInstance().getSkinResources();
    String resName = res.getResourceEntryName(resId);

    int targetResId = res.getIdentifier(resName, "dimen",
            SkinCompatResources.getInstance().getSkinPkgName());

    return targetResId == 0 ? dimen : (int) res.getDimension(targetResId);
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:15,代碼來源:SkinCompatDimenView.java

示例10: getResourceEntry

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Find an entry of resource in the overlay package provided by partners. It will first look for
 * the resource in the overlay package, and if not available, will return the one in the
 * original context.
 *
 * @return a ResourceEntry in the partner overlay's resources, if one is defined. Otherwise the
 * resources from the original context is returned. Clients can then get the resource by
 * {@code entry.resources.getString(entry.id)}, or other methods available in
 * {@link android.content.res.Resources}.
 */
public static ResourceEntry getResourceEntry(Context context, int id) {
    final Partner partner = Partner.get(context);
    if (partner != null) {
        final Resources ourResources = context.getResources();
        final String name = ourResources.getResourceEntryName(id);
        final String type = ourResources.getResourceTypeName(id);
        final int partnerId = partner.getIdentifier(name, type);
        if (partnerId != 0) {
            return new ResourceEntry(partner.mResources, partnerId, true);
        }
    }
    return new ResourceEntry(context.getResources(), id, false);
}
 
開發者ID:Trumeet,項目名稱:SetupWizardLibCompat,代碼行數:24,代碼來源:Partner.java

示例11: 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

示例12: getAvatarResourceName

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Get the resource name for a given avatar resource id.
 *
 * @param context
 * @param avatarResourceId resource id of the avatar
 * @return resource name of the avatar to be used for persistent storage.
 */
public static String getAvatarResourceName(Context context, Integer avatarResourceId) {
    Resources resources = context.getResources();
    return resources.getResourceEntryName(avatarResourceId);
}
 
開發者ID:andy1729,項目名稱:QuizApp,代碼行數:12,代碼來源:Avatars.java


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