本文整理匯總了Java中android.content.res.Resources.getSystem方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getSystem方法的具體用法?Java Resources.getSystem怎麽用?Java Resources.getSystem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.Resources
的用法示例。
在下文中一共展示了Resources.getSystem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDescription
import android.content.res.Resources; //導入方法依賴的package包/類
public String getDescription() {
final Resources res = Resources.getSystem();
if ((flags & FLAG_SD) != 0) {
if (isInteresting(label)) {
return res.getString(R.string.storage_sd_card_label, label);
} else {
return res.getString(R.string.storage_sd_card);
}
} else if ((flags & FLAG_USB) != 0) {
if (isInteresting(label)) {
return res.getString(R.string.storage_usb_drive_label, label);
} else {
return res.getString(R.string.storage_usb_drive);
}
} else {
return null;
}
}
示例2: getPreKKDefaultWallpaperInfo
import android.content.res.Resources; //導入方法依賴的package包/類
private ResourceWallpaperInfo getPreKKDefaultWallpaperInfo() {
Resources sysRes = Resources.getSystem();
int resId = sysRes.getIdentifier("default_wallpaper", "drawable", "android");
File defaultThumbFile = getDefaultThumbFile();
Bitmap thumb = null;
boolean defaultWallpaperExists = false;
if (defaultThumbFile.exists()) {
thumb = BitmapFactory.decodeFile(defaultThumbFile.getAbsolutePath());
defaultWallpaperExists = true;
} else {
Resources res = getResources();
Point defaultThumbSize = getDefaultThumbnailSize(res);
int rotation = BitmapUtils.getRotationFromExif(res, resId);
thumb = createThumbnail(
defaultThumbSize, getContext(), null, null, sysRes, resId, rotation, false);
if (thumb != null) {
defaultWallpaperExists = saveDefaultWallpaperThumb(thumb);
}
}
if (defaultWallpaperExists) {
return new ResourceWallpaperInfo(sysRes, resId, new BitmapDrawable(thumb));
}
return null;
}
示例3: getIcon
import android.content.res.Resources; //導入方法依賴的package包/類
public Drawable getIcon(int density) {
int iconRes = mResolveInfo.getIconResource();
Resources resources = null;
Drawable icon = null;
// Get the preferred density icon from the app's resources
if (density != 0 && iconRes != 0) {
try {
resources = mPm.getResourcesForApplication(mActivityInfo.applicationInfo);
icon = resources.getDrawableForDensity(iconRes, density);
} catch (NameNotFoundException | Resources.NotFoundException exc) {
}
}
// Get the default density icon
if (icon == null) {
icon = mResolveInfo.loadIcon(mPm);
}
if (icon == null) {
resources = Resources.getSystem();
icon = resources.getDrawableForDensity(android.R.mipmap.sym_def_app_icon, density);
}
return icon;
}
示例4: setFixedTextSize
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Set the text size to a given unit and value.
* <p>
* See {@link TypedValue} for the possible dimension units.
*
* @param unit The desired dimension unit.
* @param size The desired size in the given units.
*/
public void setFixedTextSize(int unit, float size) {
Context context = getContext();
Resources resources;
if (context == null) {
resources = Resources.getSystem();
} else {
resources = context.getResources();
}
setTextSize(ABSOLUTE, TypedValue.applyDimension(unit, size, resources.getDisplayMetrics()));
}
示例5: getRawSize
import android.content.res.Resources; //導入方法依賴的package包/類
private float getRawSize(int unit, float size) {
Context context = getContext();
Resources resources;
if (context == null) {
resources = Resources.getSystem();
} else {
resources = context.getResources();
}
return TypedValue.applyDimension(unit, size, resources.getDisplayMetrics());
}
示例6: getRawSize
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* 根據設備信息獲取當前分辨率下指定單位對應的像素大小;
* px,dip,sp -> px
*/
public static float getRawSize(Context c, int unit, float size) {
Resources r;
if (c == null) {
r = Resources.getSystem();
} else {
r = c.getResources();
}
return TypedValue.applyDimension(unit, size, r.getDisplayMetrics());
}
示例7: setTextSize
import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public void setTextSize(int unit, float size) {
Context c = getContext();
Resources r;
if (c == null)
r = Resources.getSystem();
else
r = c.getResources();
mMaxTextSize = TypedValue.applyDimension(unit,
size,
r.getDisplayMetrics());
mTextCachedSizes.clear();
adjustTextSize(getText().toString());
}
示例8: sp2px
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* sp轉px.
*
* @param value the value
* @param context the mContext
* @return the int
*/
public static int sp2px(float value, Context context) {
Resources r;
if (context == null) {
r = Resources.getSystem();
} else {
r = context.getResources();
}
float spvalue = value * r.getDisplayMetrics().scaledDensity;
return (int) (spvalue + 0.5f);
}
示例9: sp2px
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* sp轉px.
*
* @param value the value
* @param context the context
* @return the int
*/
public static int sp2px(float value, Context context) {
Resources r;
if (context == null) {
r = Resources.getSystem();
} else {
r = context.getResources();
}
float spvalue = value * r.getDisplayMetrics().scaledDensity;
return (int) (spvalue + 0.5f);
}
示例10: dpToPx
import android.content.res.Resources; //導入方法依賴的package包/類
private int dpToPx(float dp) {
Resources resources = Resources.getSystem();
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
}
示例11: setMinTextSize
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Set the minimum text size to a given unit and value. See TypedValue for the possible
* dimension units.
*
* @param unit The desired dimension unit.
* @param size The desired size in the given units.
* @attr ref me.grantland.R.styleable#AutofitEditText_minTextSize
*/
public AutofitHelper setMinTextSize(int unit, float size) {
Context context = mTextView.getContext();
Resources r = Resources.getSystem();
if (context != null) {
r = context.getResources();
}
setRawMinTextSize(TypedValue.applyDimension(unit, size, r.getDisplayMetrics()));
return this;
}
示例12: setMaxTextSize
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Set the maximum text size to a given unit and value. See TypedValue for the possible
* dimension units.
*
* @param unit The desired dimension unit.
* @param size The desired size in the given units.
*
* @attr ref android.R.styleable#TextView_textSize
*/
public AutofitHelper setMaxTextSize(int unit, float size) {
Context context = mTextView.getContext();
Resources r = Resources.getSystem();
if (context != null) {
r = context.getResources();
}
setRawMaxTextSize(TypedValue.applyDimension(unit, size, r.getDisplayMetrics()));
return this;
}
示例13: setMinTextSize
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Set the minimum text size to a given unit and value. See TypedValue for the possible
* dimension units.
*
* @param unit The desired dimension unit.
* @param size The desired size in the given units.
*
* @attr ref me.grantland.R.styleable#AutofitTextView_minTextSize
*/
public AutofitHelper setMinTextSize(int unit, float size) {
Context context = mTextView.getContext();
Resources r = Resources.getSystem();
if (context != null) {
r = context.getResources();
}
setRawMinTextSize(TypedValue.applyDimension(unit, size, r.getDisplayMetrics()));
return this;
}
示例14: getValueBitmapDrawable
import android.content.res.Resources; //導入方法依賴的package包/類
public Drawable getValueBitmapDrawable() {
return new BitmapDrawable(Resources.getSystem(), getValueBitmap());
}
示例15: dp2px
import android.content.res.Resources; //導入方法依賴的package包/類
private static float dp2px(float dp) {
Resources r = Resources.getSystem();
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
}