项目:AndroidBlueprints
文件:ResourcesHelper.java
/**
* get uri to any resource type
*
* @param resId - resource id
* @return - Uri to resource by given id
*/
public static Uri getUriToResource(@NonNull Activity activity,@AnyRes int resId) {
Uri resUri = null;
try {
/** Return a Resources instance for your application's package. */
Resources res = activity.getResources();
/**
* Creates a Uri which parses the given encoded URI string.
* @param uriString an RFC 2396-compliant,encoded URI
* @throws NullPointerException if uriString is null
* @return Uri for this given uri string
*/
resUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + res.getResourcePackageName(resId) + '/' + res
.getResourceTypeName(resId) + '/' + res.getResourceEntryName(resId));
/** return uri */
} catch (Resources.NotFoundException e) {
e.printstacktrace();
}
return resUri;
}
项目:android-52Kit
文件:Utils.java
/**
* Get uri to any resource type
* @param context - context
* @param resId - resource id
* @throws Resources.NotFoundException if the given ID does not exist.
* @return - Uri to resource by given id
*/
public static Uri getUriFromresource(@NonNull Context context,@AnyRes int resId) throws Resources.NotFoundException {
/** Return a Resources instance for your application's package. */
Resources res = context.getResources();
/**
* Creates a Uri which parses the given encoded URI string.
* @param uriString an RFC 2396-compliant,encoded URI
* @throws NullPointerException if uriString is null
* @return Uri for this given uri string
*/
/** return uri */
return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE +
"://" + res.getResourcePackageName(resId)
+ '/' + res.getResourceTypeName(resId)
+ '/' + res.getResourceEntryName(resId));
}
项目:SkinFramework
文件:ComposedResources.java
@Override
public void getValue(@AnyRes int id,TypedValue outValue,boolean resolveRefs) throws NotFoundException {
int realId = getCorrespondResId(id);
if (realId > 0) {
mSkinResources.getValue(realId,outValue,resolveRefs);
return;
}
super.getValue(id,resolveRefs);
}
项目:SkinFramework
文件:ComposedResources.java
@Override
public void getValueForDensity(@AnyRes int id,int density,boolean resolveRefs) throws NotFoundException {
int realId = getCorrespondResId(id);
if (realId > 0) {
mSkinResources.getValueForDensity(realId,density,resolveRefs);
return;
}
super.getValueForDensity(id,resolveRefs);
}
项目:SciChart.Android.Examples
文件:ZipAndShareTask.java
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;
}
项目:Android-skin-support
文件:SkinCompatResources.java
private void getSkinValue(Context context,@AnyRes int resId,boolean resolveRefs) {
if (!isDefaultSkin) {
int targetResId = getTargetResId(context,resId);
if (targetResId != 0) {
mResources.getValue(targetResId,resolveRefs);
return;
}
}
context.getResources().getValue(resId,resolveRefs);
}
项目:AlexaAndroid
文件:NotificationBuilder.java
/**
* get uri to drawable or any other resource type if u wish
* @param context - context
* @param drawableId - drawable res id
* @return - uri
*/
public static String getUriToDrawable(@NonNull Context context,@AnyRes int drawableId) {
String imageUri = ContentResolver.SCHEME_ANDROID_RESOURCE +
"://" + context.getResources().getResourcePackageName(drawableId)
+ '/' + context.getResources().getResourceTypeName(drawableId)
+ '/' + context.getResources().getResourceEntryName(drawableId);
return imageUri;
}
项目:Chemistry
文件:ViewTypes.java
@ViewType
@AnyRes
public static int generate() {
int result;
for (; ; ) {
result = sNextGeneratedId.get();
// aapt-generated IDs have the high byte nonzero; clamp to the range under that.
final int newValue = (result + 1) & 0x00FFFFFF;
if (sNextGeneratedId.compareAndSet(result,newValue)) {
break;
}
}
return CUSTOM_PACKAGE_NAMESPACE_RES | result;
}
项目:android-wheels
文件:CommonUtils.java
/**
* Get {@link Uri} representing given resource
*
* @param context Context
* @param resourceId Resource identifier
* @return Resource uri
*/
@NonNull
public static Uri getResourceUri(@NonNull Context context,@AnyRes int resourceId) {
Resources resources = context.getResources();
return Uri
.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + resources.getResourcePackageName(resourceId) +
"/" + resources.getResourceTypeName(resourceId) + "/" +
resources.getResourceEntryName(resourceId));
}
项目:luxunPro
文件:EMResourceUtil.java
/**
* Resolves the reference to an attribute,returning the root resource id.
*
* @param context The context to use when determining the root id
* @param attr The attribute to resolve
* @return The resource id pointing to the de-referenced attribute
*/
@AnyRes
public static int getResolvedResourceId(Context context,@AttrRes int attr) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(attr,typedValue,true);
if (typedValue.type == TypedValue.TYPE_REFERENCE) {
return typedValue.data;
}
return typedValue.resourceId;
}
项目:external-resources
文件:ExternalResources.java
@Nullable private String getApplicationResourceEntryName(@AnyRes int resId)
throws IllegalStateException {
if (!useApplicationResources) {
throw new IllegalStateException(
"You have set the useApplicationResources to false,using application resource is an error.");
}
return Utils.getAndroidResourceEntryName(context,resId);
}
项目:external-resources
文件:Utils.java
@Nullable public static String getAndroidResourceEntryName(Context context,@AnyRes int resId) {
try {
return context.getResources().getResourceEntryName(resId);
} catch (android.content.res.Resources.NotFoundException e) {
return null;
}
}
项目:ExoMedia
文件:ResourceUtil.java
/**
* Resolves the reference to an attribute,true);
if (typedValue.type == TypedValue.TYPE_REFERENCE) {
return typedValue.data;
}
return typedValue.resourceId;
}
项目:ThemeEngine
文件:Theme.java
@Nullable
public static Res get(Context context,@AnyRes int resId) {
if (resId == 0) {
return null;
}
return new Res(context.getResources().getResourceTypeName(resId),context.getResources().getResourceEntryName(resId));
}
项目:penn-mobile-android
文件:BusRoute.java
/**
* Provide appropriate colors for each bus route.
* @return Color as an int,output of `Color.rgb`
*/
@AnyRes
public int getColor() {
switch (route_name) {
case "Campus Loop":
return Color.rgb(76,175,80);
case "PennBUS West":
return Color.rgb(244,67,54);
case "PennBUS East":
return Color.rgb(63,81,181);
}
return Color.GRAY;
}
项目:apps-android-wikipedia
文件:ResourceUtil.java
/**
* Resolves the resource ID of a theme-dependent attribute (for example,a color value
* that changes based on the selected theme)
* @param context The context whose theme contains the attribute.
* @param id Theme-dependent attribute ID to be resolved.
* @return The actual resource ID of the requested theme-dependent attribute.
*/
@AnyRes public static int getThemedAttributeId(@NonNull Context context,@AttrRes int id) {
TypedValue typedValue = getThemedAttribute(context,id);
if (typedValue == null) {
throw new IllegalArgumentException("Attribute not found; ID=" + id);
}
return typedValue.resourceId;
}
项目:apps-android-wikipedia
文件:ResourceUtil.java
public static Uri uri(@NonNull Context context,@AnyRes int id) throws Resources.NotFoundException {
Resources res = context.getResources();
return new Uri.Builder()
.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(res.getResourcePackageName(id))
.appendpath(res.getResourceTypeName(id))
.appendpath(res.getResourceEntryName(id))
.build();
}
项目:letv
文件:TypedArrayUtils.java
@AnyRes
public static int getResourceId(TypedArray a,@StyleableRes int index,@StyleableRes int fallbackIndex,@AnyRes int defaultValue) {
return a.getResourceId(index,a.getResourceId(fallbackIndex,defaultValue));
}
@AnyRes
public static int getResourceId(TypedArray a,defaultValue));
}
项目:Android-skin-support
文件:SkinCompatResources.java
public static void getValue(Context context,boolean resolveRefs) {
getInstance().getSkinValue(context,resId,resolveRefs);
}
项目:jigsaw-android
文件:ResUtils.java
public static Uri getUriOfResource(@NonNull Context context,@AnyRes int resId) {
return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE +
"://" + context.getResources().getResourcePackageName(resId)
+ '/' + context.getResources().getResourceTypeName(resId)
+ '/' + context.getResources().getResourceEntryName(resId));
}
@AnyRes
int getvariableId();
项目:Chemistry
文件:BasicChemistry.java
@ViewType
@AnyRes
public abstract int getViewType();
项目:Chemistry
文件:BasicChemistry.java
public final <RI extends Item> Boiler<RI,VH> wrap(@ViewType @AnyRes int viewType) {
return compose(viewType,this);
}
项目:Chemistry
文件:BasicChemistry.java
public final Boiler<Item,VH> useViewType(@ViewType @AnyRes int viewType) {
return compose(this).useViewType(viewType);
}
项目:Chemistry
文件:BasicChemistry.java
public Boiler<Item,VH> useViewType(@ViewType @AnyRes int viewType) {
ViewTypes.validateArgument(viewType);
this.viewType = viewType;
return this;
}
项目:Chemistry
文件:BasicChemistry.java
public Preperator<Item> useViewType(@ViewType @AnyRes int viewType) {
ViewTypes.validateArgument(viewType);
this.viewType = viewType;
return this;
}
项目:Chemistry
文件:Chemistry.java
@ViewType
@AnyRes
public abstract int getItemViewType(Item item);
项目:Chemistry
文件:Chemistry.java
public static <Item> BasicChemistry.Preperator<Item> compose(@ViewType @AnyRes int viewType) {
return new BasicChemistry.Preperator<Item>().useViewType(viewType);
}
项目:Chemistry
文件:Chemistry.java
public static <Item,VH extends ViewHolder> BasicChemistry.Boiler<Item,VH> compose(@ViewType @AnyRes int viewType,@NonNull BasicChemistry<? super Item,VH> base) {
return new BasicChemistry.Boiler<>(base).useViewType(viewType);
}
项目:Chemistry
文件:TypeSelector.java
@ViewType
@AnyRes
int getItemViewType(Item item);
项目:Chemistry
文件:ViewTypes.java
@SuppressWarnings("Range")
@ViewType
@AnyRes
private static int invalid() {
return RecyclerView.INVALID_TYPE;
}
项目:Android-App-Template
文件:ResourcesUtil.java
public static String getResourceEntryName(@AnyRes int anyRes) {
return ContextUtil.getResources().getResourceEntryName(anyRes);
}
项目:Android-App-Template
文件:ResourcesUtil.java
public static String getResourceName(@AnyRes int anyRes) {
return ContextUtil.getResources().getResourceName(anyRes);
}
项目:Android-App-Template
文件:ResourcesUtil.java
public static String getResourcePackageName(@AnyRes int anyRes) {
return ContextUtil.getResources().getResourcePackageName(anyRes);
}
项目:Android-App-Template
文件:ResourcesUtil.java
public static String getResourceTypeName(@AnyRes int anyRes) {
return ContextUtil.getResources().getResourceTypeName(anyRes);
}
项目:Android-App-Template
文件:ResourcesUtil.java
public static void getValue(@AnyRes int anyRes,boolean resolveRefs) {
ContextUtil.getResources().getValue(anyRes,resolveRefs);
}
项目:Android-App-Template
文件:ResourcesUtil.java
public static void getValueForDensity(@AnyRes int anyRes,boolean resolveRefs) {
if (APILevel.require(15))
ContextUtil.getResources().getValueForDensity(anyRes,resolveRefs);
else
ContextUtil.getResources().getValue(anyRes,resolveRefs);
}
项目:ThemeEngine
文件:Theme.java
/**
* Gets id from theme apk
*/
@AnyRes
public static int getId(Context context,String type,String name) {
return getResources(context).getIdentifier(name,type,getPackageName());
}
项目:penn-mobile-android
文件:MainActivity.java
private void navigateLayout(@AnyRes int id) {
Fragment fragment = null;
switch (id) {
case R.id.nav_home:
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
fragment = new MainFragment();
}
break;
case R.id.nav_registrar:
case R.id.registrar_cont:
fragment = new RegistrarFragment();
break;
case R.id.nav_directory:
fragment = new DirectoryFragment();
break;
case R.id.nav_gsr:
case R.id.gsr_cont:
fragment = new GsrFragment();
break;
case R.id.nav_dining:
case R.id.dining_cont:
fragment = new DiningFragment();
break;
case R.id.nav_news:
case R.id.news_cont:
fragment = new NewsFragment();
break;
case R.id.nav_map:
case R.id.map_cont:
getPermission();
return;
case R.id.nav_laundry:
case R.id.laundry_cont:
/*
fragment = new LaundryFragment();
if (from_alarm) {
from_alarm = false;
Bundle arg = new Bundle();
arg.putInt(getString(R.string.laundry_hall_no),getIntent().getIntExtra(getString(R.string.laundry_hall_no),-1));
fragment.setArguments(arg);
}
*/
Intent intent = new Intent(this,LaundryActivity.class);
startActivity(intent);
break;
// case R.id.nav_nso:
// case R.id.nso_cont:
// fragment = new NsoFragment();
// break;
case R.id.nav_support:
fragment = new SupportFragment();
break;
case R.id.nav_about:
fragment = new AboutFragment();
break;
case R.id.nav_pref:
fragment = new PreferenceFragment();
break;
}
fragmentTransact(fragment);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。