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


Java Resources.getSystem方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:19,代碼來源:DiskInfo.java

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

示例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;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:23,代碼來源:LauncherActivityInfoCompatV16.java

示例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()));
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:19,代碼來源:SubtitleView.java

示例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());
}
 
開發者ID:Zackratos,項目名稱:PureMusic,代碼行數:11,代碼來源:LyricView.java

示例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());
}
 
開發者ID:wzc25151,項目名稱:lrs_android,代碼行數:14,代碼來源:DisplayUtil.java

示例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());
}
 
開發者ID:eyeRS,項目名稱:eyeRS,代碼行數:16,代碼來源:AutoResizeTextView.java

示例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);
}
 
開發者ID:chenzj-king,項目名稱:RetrofitSample,代碼行數:18,代碼來源:PixelUtil.java

示例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);
}
 
開發者ID:CoderCF,項目名稱:SuperVideoPlayer,代碼行數:18,代碼來源:PixelUtil.java

示例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());
}
 
開發者ID:DysaniazzZ,項目名稱:ArtOfAndroid,代碼行數:5,代碼來源:CircleView.java

示例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;
}
 
開發者ID:victorminerva,項目名稱:AutoResizeEditText,代碼行數:20,代碼來源:AutofitHelper.java

示例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;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:21,代碼來源:AutofitHelper.java

示例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;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:21,代碼來源:AutofitHelper.java

示例14: getValueBitmapDrawable

import android.content.res.Resources; //導入方法依賴的package包/類
public Drawable getValueBitmapDrawable() {
    return new BitmapDrawable(Resources.getSystem(), getValueBitmap());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:DynamicProperty.java

示例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());
}
 
開發者ID:hushengjun,項目名稱:FastAndroid,代碼行數:5,代碼來源:SwitchButton.java


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