微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.content.res.Resources的实例源码

项目:TreebolicLib    文件Utils.java   
/**
 * Get drawable
 *
 * @param context context
 * @param resId   drawable id
 * @return drawable
 */
static public Drawable getDrawable(@NonNull final Context context,int resId)
{
    final Resources resources = context.getResources();
    Drawable drawable;
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP)
    {
        final Resources.Theme theme = context.getTheme();
        drawable = resources.getDrawable(resId,theme);
    }
    else
    {
        drawable = resources.getDrawable(resId);
    }
    return drawable;
}
项目:GitHub    文件MDRootLayout.java   
private void init(Context context,AttributeSet attrs,int defStyleAttr) {
    Resources r = context.getResources();

    TypedArray a = context.obtainStyledAttributes(attrs,R.styleable.MDRootLayout,defStyleAttr,0);
    reducePaddingNoTitleNoButtons = a.getBoolean(R.styleable.MDRootLayout_md_reduce_padding_no_title_no_buttons,true);
    a.recycle();

    noTitlePaddingFull = r.getDimensionPixelSize(R.dimen.md_notitle_vertical_padding);
    buttonPaddingFull = r.getDimensionPixelSize(R.dimen.md_button_frame_vertical_padding);

    buttonHorizontalEdgeMargin = r.getDimensionPixelSize(R.dimen.md_button_padding_frame_side);
    buttonbarHeight = r.getDimensionPixelSize(R.dimen.md_button_height);

    dividerPaint = new Paint();
    dividerWidth = r.getDimensionPixelSize(R.dimen.md_divider_height);
    dividerPaint.setColor(DialogUtils.resolveColor(context,R.attr.md_divider_color));
    setwillNotDraw(false);
}
项目:FastTextView    文件FastTextView.java   
private void init(Context context,@Nullable AttributeSet attrs,int defStyleAttr,int
    defStyleRes) {
  mAttrsHelper.init(context,attrs,defStyleRes);
  setText(mAttrsHelper.mText);
  TextPaint textPaint = getTextPaint();
  textPaint.setColor(mAttrsHelper.mTextColor);
  textPaint.setTextSize(mAttrsHelper.mTextSize);
  final Resources.Theme theme = context.getTheme();
  TypedArray a = theme.obtainStyledAttributes(attrs,R.styleable.FastTextView,defStyleRes);
  mEnableLayoutCache = a.getBoolean(R.styleable.FastTextView_enableLayoutCache,false);
  a.recycle();
}
项目:sflauncher    文件App.java   
private static Shortcut from(Card.Apps c,String ident){
    String[] parts = ident.split("\\|");
    Context ctx = c.getWrapper().getContext();
    if(parts[0].equals("shortcut4") && parts.length >= 5){
        try {
            Resources res = ctx.getPackageManager().getResourcesForApplication(parts[1]);
            int drawableIdent = res.getIdentifier(parts[4],"drawable",parts[1]);
            Drawable icon = res.getDrawable(drawableIdent);
            String uri = decodeText(parts[2]);
            Intent intent = Intent.parseUri(uri,Intent.URI_INTENT_SCHEME);
            return new Shortcut(parts[3],icon,parts[1],intent,drawableIdent);
        } catch (PackageManager.NameNotFoundException | URISyntaxException |
                    Resources.NotFoundException ignored) {
        }
    }
    return null;
}
项目:GitHub    文件SystemBarTintManager.java   
@TargetApi(14)
private int getNavigationBarHeight(Context context) {
    Resources res = context.getResources();
    int result = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (hasNavBar(context)) {
            String key;
            if (mInPortrait) {
                key = NAV_BAR_HEIGHT_RES_NAME;
            } else {
                key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME;
            }
            return getInternalDimensionSize(res,key);
        }
    }
    return result;
}
项目:AliZhiBoHao    文件MenuDialog.java   
private void init(Context context) {
    setorientation(VERTICAL);

    Resources r = context.getResources();
    int pxPadding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,8,r.getdisplayMetrics());

    setPadding(pxPadding,pxPadding,pxPadding);

    LayoutInflater layoutInflater = LayoutInflater.from(context);
    View view = layoutInflater.inflate(R.layout.menu_dialog,this);
    mStreamEditText = (EditText) view.findViewById(R.id.stream_url);
    mResolutionGroup = (RadioGroup)view.findViewById(R.id.resolution);
    mResolutionGroup.check(R.id.resolution_hight);

    mOrientationGroup = (RadioGroup)view.findViewById(R.id.orientation);
    mOrientationGroup.check(R.id.orientation_landscape);
}
项目:Hands-On-Android-UI-Development    文件ItemPresenter.java   
public Drawable getCategoryIcon(final Category category) {
    final Resources resources = context.getResources();

    switch (category) {
        case ACCOMMODATION:
            return resources.getDrawable(R.drawable.ic_hotel_black);
        case FOOD:
            return resources.getDrawable(R.drawable.ic_food_black);
        case TRANSPORT:
            return resources.getDrawable(R.drawable.ic_transport_black);
        case ENTERTAINMENT:
            return
                    resources.getDrawable(R.drawable.ic_entertainment_black);
        case BUSInesS:
            return resources.getDrawable(R.drawable.ic_business_black);
        case OTHER:
        default:
            return resources.getDrawable(R.drawable.ic_other_black);
    }
}
项目:RLibrary    文件BitmapUtil.java   
/**
 * 获取压缩后的图片
 *
 * @param res
 * @param resId
 * @param reqWidth  所需图片压缩尺寸最小宽度
 * @param reqHeight 所需图片压缩尺寸最小高度
 * @return
 */
public static Bitmap decodeSampledBitmapFromresource(Resources res,int resId,int reqWidth,int reqHeight) {
    /**
     * 1.获取图片的像素宽高(不加载图片至内存中,所以不会占用资源)
     * 2.计算需要压缩的比例
     * 3.按将图片用计算出的比例压缩,并加载至内存中使用
     */
    // 首先不加载图片,仅获取图片尺寸
    final BitmapFactory.Options options = new BitmapFactory.Options();
    // 当inJustDecodeBounds设为true时,不会加载图片获取图片尺寸信息
    options.inJustDecodeBounds = true;
    // 此时仅会将图片信息会保存至options对象内,decode方法不会返回bitmap对象
    BitmapFactory.decodeResource(res,resId,options);

    // 计算压缩比例,如inSampleSize=4时,图片会压缩成原图的1/4
    options.inSampleSize = calculateInSampleSize(options,reqWidth,reqHeight);

    // 当inJustDecodeBounds设为false时,BitmapFactory.decode...就会返回图片对象了
    options.inJustDecodeBounds = false;
    options.inScaled = false;
    // 利用计算的比例值获取压缩后的图片对象
    return BitmapFactory.decodeResource(res,options);
}
项目:cwac-crossport    文件FloatingActionButton.java   
private int getSizeDimension(@Size final int size) {
  final Resources res = getResources();
  switch (size) {
    case SIZE_AUTO:
      // If we're set to auto,grab the size from resources and refresh
              final int width = res.getConfiguration().screenWidthDp;
              final int height = res.getConfiguration().screenHeightDp;
      return Math.max(width,height) < AUTO_MINI_LARGEST_SCREEN_WIDTH
          ? getSizeDimension(SIZE_MINI)
          : getSizeDimension(SIZE_norMAL);
    case SIZE_MINI:
      return res.getDimensionPixelSize(R.dimen.design_fab_size_mini);
    case SIZE_norMAL:
    default:
      return res.getDimensionPixelSize(R.dimen.design_fab_size_normal);
  }
}
项目:meat-grinder    文件ResultItemHolder.java   
public void onBind(@NonNull CheckInfo checkInfo,int position) {
    if (mCheckInfo != null && mCheckInfo.equals(checkInfo)) {
        return;
    }
    mCheckInfo = checkInfo;
    Resources res = itemView.getResources();
    String desc = res.getString(ChecksHelper.getCheckStringId(mCheckInfo.getTypeCheck()));
    title.setText(desc);
    if (mCheckInfo.getState() == null) {
        icon.setimageBitmap(getNonCheck(itemView.getContext()));
    } else if (mCheckInfo.getState() == Boolean.TRUE) {
        icon.setimageBitmap(getFound(itemView.getContext()));
    } else {
        icon.setimageBitmap(getok(itemView.getContext()));
    }

}
项目:ImmerseMode    文件ActivityConfig.java   
private int getNavigationBarHeight(Context context) {
    Resources res = context.getResources();
    int result = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (hasNavBar(context)) {
            String key;
            if (mInPortrait) {
                key = NAV_BAR_HEIGHT_RES_NAME;
            } else {
                key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME;
            }
            return ResourcesUtils.getDimensionSize(res,key,"android");
        }
    }
    return result;
}
项目:aarLibrary    文件XRefreshViewHeader.java   
public void setRefreshTime(long lastRefreshTime) {
    // 获取当前时间
    Calendar mCalendar = Calendar.getInstance();
    long refreshTime = mCalendar.getTimeInMillis();
    long howLong = refreshTime - lastRefreshTime;
    int minutes = (int) (howLong / 1000 / 60);
    String refreshTimeText = null;
    Resources resources = getContext().getResources();
    if (minutes < 1) {
        refreshTimeText = resources
                .getString(R.string.xrefreshview_refresh_justNow);
    } else if (minutes < 60) {
        refreshTimeText = resources
                .getString(R.string.xrefreshview_refresh_minutes_ago);
        refreshTimeText = Utils.format(refreshTimeText,minutes);
    } else if (minutes < 60 * 24) {
        refreshTimeText = resources
                .getString(R.string.xrefreshview_refresh_hours_ago);
        refreshTimeText = Utils.format(refreshTimeText,minutes / 60);
    } else {
        refreshTimeText = resources
                .getString(R.string.xrefreshview_refresh_days_ago);
        refreshTimeText = Utils.format(refreshTimeText,minutes / 60 / 24);
    }
    mHeaderTimeTextView.setText(refreshTimeText);
}
项目:LaunchEnr    文件AutoInstallsLayout.java   
AutoInstallsLayout(Context context,AppWidgetHost appWidgetHost,LayoutParserCallback callback,Resources res,int layoutId,String roottag) {
    mContext = context;
    mAppWidgetHost = appWidgetHost;
    mCallback = callback;

    mPackageManager = context.getPackageManager();
    mValues = new ContentValues();
    mRoottag = roottag;

    mSourceRes = res;
    mLayoutId = layoutId;

    mIdp = LauncherAppState.getIDP(context);
    mRowCount = mIdp.numRows;
    mColumnCount = mIdp.numColumns;
}
项目:SimpleUILauncher    文件Workspace.java   
/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused.
 */
public Workspace(Context context,int defStyle) {
    super(context,defStyle);

    mLauncher = Launcher.getLauncher(context);
    mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher,this);
    final Resources res = getResources();
    DeviceProfile grid = mLauncher.getDeviceProfile();
    mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens();
    mWallpaperManager = WallpaperManager.getInstance(context);

    mWallpaperOffset = new WallpaperOffsetInterpolator(this);
    mOverviewmodeShrinkFactor =
            res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100f;

    setonHierarchychangelistener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);
}
项目:SimpleUILauncher    文件DragLayer.java   
/**
 * Used to create a new DragLayer from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 */
public DragLayer(Context context,AttributeSet attrs) {
    super(context,attrs);

    // disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(false);
    setChildrenDrawingOrderEnabled(true);

    final Resources res = getResources();
    mLeftHoverDrawable = res.getDrawable(R.drawable.page_hover_left);
    mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right);
    mLeftHoverDrawableActive = res.getDrawable(R.drawable.page_hover_left_active);
    mRightHoverDrawableActive = res.getDrawable(R.drawable.page_hover_right_active);
    mIsRtl = Utilities.isRtl(res);
    mFocusIndicatorHelper = new ViewGroupFocusHelper(this);
}
项目:SuperSelector    文件ImageResizer.java   
/**
 * Decode and sample down a bitmap from resources to the requested width and
 * height.
 * 
 * @param res
 *            The resources object containing the image data
 * @param resId
 *            The resource id of the image data
 * @param reqWidth
 *            The requested width of the resulting bitmap
 * @param reqHeight
 *            The requested height of the resulting bitmap
 * @param cache
 *            The ImageCache used to find candidate bitmaps for use with
 *            inBitmap
 * @return A bitmap sampled down from the original with the same aspect
 *         ratio and dimensions that are equal to or greater than the
 *         requested width and height
 */
public static Bitmap decodeSampledBitmapFromresource(Resources res,int reqHeight,ImageCache cache) {

    // BEGIN_INCLUDE (read_bitmap_dimensions)
    // First decode with inJustDecodeBounds=true to check dimensions
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(res,options);

    // Calculate inSampleSize
    options.inSampleSize = calculateInSampleSize(options,reqHeight);
    // END_INCLUDE (read_bitmap_dimensions)

    // If we're running on Honeycomb or newer,try to use inBitmap
    if (Utils.hasHoneycomb()) {
        addInBitmapOptions(options,cache);
    }

    // Decode bitmap with inSampleSize set
    options.inJustDecodeBounds = false;
    return BitmapFactory.decodeResource(res,options);
}
项目:microMathematics    文件AppLocale.java   
@SuppressWarnings("deprecation")
public static Contextwrapper wrap(Context context,Locale newLocale)
{
    final Resources res = context.getResources();
    final Configuration configuration = res.getConfiguration();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
    {
        configuration.setLocale(newLocale);
        LocaleList localeList = new LocaleList(newLocale);
        LocaleList.setDefault(localeList);
        configuration.setLocales(localeList);
        context = context.createConfigurationContext(configuration);
    }
    else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
    {
        configuration.setLocale(newLocale);
        context = context.createConfigurationContext(configuration);
    }
    else
    {
        configuration.locale = newLocale;
        res.updateConfiguration(configuration,res.getdisplayMetrics());
    }
    return new Contextwrapper(context);
}
项目:FlickLauncher    文件AllAppsContainerView.java   
public AllAppsContainerView(Context context,int defStyleAttr) {
    super(context,defStyleAttr);
    Resources res = context.getResources();

    mLauncher = Launcher.getLauncher(context);
    mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
    mApps = new AlphabeticalAppsList(context);
    mAdapter = new AllAppsGridAdapter(mLauncher,mApps,mLauncher,this);
    mApps.setAdapter(mAdapter);
    mLayoutManager = mAdapter.getLayoutManager();
    mItemdecoration = mAdapter.getItemdecoration();
    DeviceProfile grid = mLauncher.getDeviceProfile();
    if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && !grid.isverticalBarLayout()) {
        mRecyclerViewBottomPadding = 0;
        setPadding(0,0);
    } else {
        mRecyclerViewBottomPadding =
                res.getDimensionPixelSize(R.dimen.all_apps_list_bottom_padding);
    }
    mSearchQueryBuilder = new SpannableStringBuilder();
    Selection.setSelection(mSearchQueryBuilder,0);

}
项目:HeroVideo-master    文件MediaPlayer.java   
public float pixel2dip(Context context,float n){
    Resources resources = context.getResources();
    displayMetrics metrics = resources.getdisplayMetrics();
    float dp = n / (metrics.densityDpi / 160f);
    return dp;

}
项目:ClouldReader    文件CloudReaderApplication.java   
/**
 * 使其系统更改字体大小无效
 */
private void initTextSize() {
    Resources res = getResources();
    Configuration config = new Configuration();
    config.setToDefaults();
    res.updateConfiguration(config,res.getdisplayMetrics());
}
项目:phonk    文件PUtil.java   
@ProtoMethod(description = "Convert given dp to pixels",example = "")
@ProtoMethodParam(params = {""})
public float dpToPixels(float dp) {
    Resources resources = getContext().getResources();
    displayMetrics metrics = resources.getdisplayMetrics();
    float px = dp * (metrics.densityDpi / 160f);
    return px;
}
项目:firefox-tv    文件ErrorPage.java   
public static void loadErrorPage(final AmazonWebView webView,final String desiredURL,final int errorCode) {
    final Pair<Integer,Integer> errorResourceIDs = errorDescriptionMap.get(errorCode);

    if (errorResourceIDs == null) {
        throw new IllegalArgumentException("Cannot load error description for unsupported errorcode=" + errorCode);
    }

    // This is quite hacky: ideally we'd just load the css file directly using a '<link rel="stylesheet"'.
    // However WebView thinks it's still loading the original page,which can be an https:// page.
    // If mixed content blocking is enabled (which is probably what we want in Focus),then webkit
    // will block file:///android_res/ links from being loaded - which blocks our css from being loaded.
    // We Could hack around that by enabling mixed content when loading an error page (and reenabling it
    // once that's loaded),but doing that correctly and reliably isn't particularly simple. Loading
    // the css data and stuffing it into our html is much simpler,especially since we're already doing
    // string substitutions.
    // As an added bonus: file:/// URIs are broken if the app-id != app package,see:
    // https://code.google.com/p/android/issues/detail?id=211768 (this breaks loading css via file:///
    // references when running debug builds,and probably klar too) - which means this wouldn't
    // be possible even if we hacked around the mixed content issues.
    final String cssstring = HtmlLoader.loadResourceFile(webView.getContext(),R.raw.errorpage_style,null);

    final Map<String,String> substitutionMap = new ArrayMap<>();

    final Resources resources = webView.getContext().getResources();

    substitutionMap.put("%page-title%",resources.getString(R.string.errorpage_title));
    substitutionMap.put("%button%",resources.getString(R.string.errorpage_refresh));

    substitutionMap.put("%messageShort%",resources.getString(errorResourceIDs.first));
    substitutionMap.put("%messageLong%",resources.getString(errorResourceIDs.second,desiredURL));

    substitutionMap.put("%css%",cssstring);

    final String errorPage = HtmlLoader.loadResourceFile(webView.getContext(),R.raw.errorpage,substitutionMap);

    // We Could load the raw html file directly into the webview using a file:///android_res/
    // URI - however we'd then need to do some JS hacking to do our String substitutions. Moreover
    // we'd have to deal with the mixed-content issues detailed above in that case.
    webView.loadDataWithBaseURL(desiredURL,errorPage,"text/html","UTF8",desiredURL);
}
项目:Android-2017    文件MainActivity.java   
@Override
public void onClick (View view) {
    String strNumeroGatitos;
    int intNumeroGatitos = -1;
    // objeto recursos para el acceso a los mismos
    Resources res = this.getResources();

    // recuperar la vista con la respuesta a la pregunta
    EditText txtGatitos  = (EditText) findViewById(R.id.preguntaGatitos);
    // recuperar la respuesta a la pregunta (como texto)
    strNumeroGatitos = txtGatitos.getText().toString();

    try {
        // convertir el valor introducido en el Edit Text a numerico
        intNumeroGatitos = Integer.parseInt(strNumeroGatitos);
    }
    catch (NumberFormatException ex) {
        // controlamos el error en caso que no se haya introducido un numero
        Toast.makeText(this,R.string.error_numerico,Toast.LENGTH_LONG).show();
        intNumeroGatitos = -1;
    }

    // mostrar un mensaje en función del número de gatitos
    if (intNumeroGatitos != -1) {
        // recuepramos la vista respuesta
        TextView txtRespuesta = (TextView) findViewById(R.id.respuestaGatitos);
        // el segundo parámetro sirve para seleccional que forma se ha de usar.
        // el tercer parámetro es opcional. Si se ha indicado formato en la cadena un formato debemos indicar aquí
        // los parámetros requeridos.
        txtRespuesta.setText(res.getQuantityString(R.plurals.gatitos,intNumeroGatitos,intNumeroGatitos));

    }
}
项目:simple-stack    文件TasksPresenter.java   
@Inject
public TasksPresenter(Backstack backstack,TaskRepository taskRepository,MessageQueue messageQueue,Resources resources) {
    this.backstack = backstack;
    this.taskRepository = taskRepository;
    this.messageQueue = messageQueue;
    this.resources = resources;
}
项目:easyfilemanager    文件MaterialProgressDialog.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Resources res = getContext().getResources();
    mDefaultColor = res.getColor(R.color.accentColor);

    indeterminateDrawable = new MaterialProgressDrawable(getContext(),findViewById(android.R.id.progress));
    indeterminateDrawable.setBackgroundColor(CIRCLE_BG_LIGHT);
    indeterminateDrawable.setAlpha(255);
    indeterminateDrawable.updateSizes(MaterialProgressDrawable.XLARGE);
    indeterminateDrawable.setColorSchemeColors(getColor());
    indeterminateDrawable.start();
    setIndeterminateDrawable(indeterminateDrawable);
}
项目:igrow-android    文件EnvironmentalSensorsviewmodelTest.java   
private void setupContext() {
    when(mContext.getApplicationContext()).thenReturn(mContext);
    when(mContext.getString(R.string.successfully_saved_sensor_message))
            .thenReturn("EDIT_RESULT_OK");
    when(mContext.getString(R.string.successfully_added_sensor_message))
            .thenReturn("ADD_EDIT_RESULT_OK");
    when(mContext.getString(R.string.successfully_deleted_sensor_message))
            .thenReturn("DELETE_RESULT_OK");

    when(mContext.getResources()).thenReturn(mock(Resources.class));
}
项目:chromium-for-android-56-debug-video    文件MostVisitedLayout.java   
/**
 * @param context The view context in which this item will be shown.
 * @param attrs The attributes of the XML tag that is inflating the view.
 */
public MostVisitedLayout(Context context,attrs);

    Resources res = getResources();
    mVerticalSpacing = res.getDimensionPixelOffset(R.dimen.most_visited_vertical_spacing);
    mMinHorizontalSpacing = res.getDimensionPixelOffset(
            R.dimen.most_visited_min_horizontal_spacing);
    mMaxHorizontalSpacing = res.getDimensionPixelOffset(
            R.dimen.most_visited_max_horizontal_spacing);
    mMaxWidth = res.getDimensionPixelOffset(R.dimen.most_visited_layout_max_width);
}
项目:KUtils    文件SystemBarTintManager.java   
private int getInternalDimensionSize(Resources res,String key) {
    int result = 0;
    int resourceId = res.getIdentifier(key,"dimen","android");
    if (resourceId > 0) {
        result = res.getDimensionPixelSize(resourceId);
    }
    return result;
}
项目:JPSpringMenu    文件SpringMenu.java   
private int getStatusBarHeight() {
    Resources resources = getResources();
    int resourceId = resources.getIdentifier("status_bar_height","android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }
    return 0;
}
项目:LucaHome-MediaServer    文件SnakeView.java   
@SuppressWarnings("deprecation")
private void initSnakeView() {
    _logger = new SmartMirrorLogger(TAG);
    _logger.Debug("SnakeView created...");

    setFocusable(true);

    Resources resources = this.getContext().getResources();

    ResetTiles(4);

    LoadTile(RED_STAR,resources.getDrawable(R.drawable.redstar));
    LoadTile(YELLOW_STAR,resources.getDrawable(R.drawable.yellowstar));
    LoadTile(GREEN_STAR,resources.getDrawable(R.drawable.greenstar));
}
项目:chromium-for-android-56-debug-video    文件NotificationBuilderBase.java   
public NotificationBuilderBase(Resources resources) {
    mLargeIconWidthPx =
            resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
    mLargeIconHeightPx =
            resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
    mIconGenerator = createIconGenerator(resources);
}
项目:android_ui    文件LinearProgressDrawable.java   
/**
 * Creates a new instance of LinearProgressDrawable from the specified <var>state</var>.
 *
 * @param state The state from which to create the new progress drawable instance.
 * @param res   An application resources.
 * @param theme A theme to be applied to the new progress drawable instance.
 */
private LinearProgressDrawable(LinearState state,Resources.Theme theme) {
    if (theme != null && state.canApplyTheme()) {
        changeConstantState(mProgressstate = new LinearState(state));
        applyTheme(theme);
    } else {
        changeConstantState(mProgressstate = state);
    }
    this.mBackgroundTintFilter = TintDrawable.createTintFilter(this,state.backgroundTint,state.backgroundTintMode);
    this.mProgresstintFilter = TintDrawable.createTintFilter(this,state.progresstint,state.progresstintMode);
    this.mSecondaryProgresstintFilter = TintDrawable.createTintFilter(this,state.secondaryProgresstint,state.secondaryProgresstintMode);
    this.mIndeterminateTintFilter = TintDrawable.createTintFilter(this,state.indeterminateTint,state.indeterminateTintMode);
}
项目:brickkit-android    文件BrickSizeTest.java   
@Before
public void setup() {
    configuration = new Configuration();

    resources = mock(Resources.class);
    when(resources.getConfiguration()).thenReturn(configuration);

    context = mock(Context.class);
    when(context.getResources()).thenReturn(resources);

    brick = mock(BaseBrick.class);

    brickSize = new TestBrickSize();
    brickSize.setBaseBrick(brick);
}
项目:mvvm-template    文件DynamicRecyclerView.java   
public void addKeyLineDivider() {
    if (canAddDivider()) {
        Resources resources = getResources();
        addItemdecoration(new InsetDividerdecoration(resources.getDimensionPixelSize(R.dimen.divider_height),resources.getDimensionPixelSize(R.dimen.keyline_2),ViewHelper.getListDivider(getContext())));
    }
}
项目:GitHub    文件DeviceInfoTests.java   
private Context mockContextForTestingDensity(final int density) {
    final displayMetrics metrics = new displayMetrics();
    metrics.densityDpi = density;
    final Resources mockResources = mock(Resources.class);
    when(mockResources.getdisplayMetrics()).thenReturn(metrics);
    final Context mockContext = mock(Context.class);
    when(mockContext.getResources()).thenReturn(mockResources);
    return mockContext;
}
项目:KUtils-master    文件SystemBarTintManager.java   
private int getInternalDimensionSize(Resources res,"android");
    if (resourceId > 0) {
        result = res.getDimensionPixelSize(resourceId);
    }
    return result;
}
项目:AssistantBySDK    文件LingjuSwipeRefreshLayout.java   
/**
 * Set the color resources used in the progress animation from color resources.
 * The first color will also be the color of the bar that grows in response
 * to a user swipe gesture.
 *
 * @param colorResIds
 */
public void setColorSchemeResources(int... colorResIds) {
    final Resources res = getResources();
    int[] colorRes = new int[colorResIds.length];
    for (int i = 0; i < colorResIds.length; i++) {
        colorRes[i] = res.getColor(colorResIds[i]);
    }
    setColorSchemeColors(colorRes);
}
项目:FireFiles    文件ConnectionsFragment.java   
@Override
public void onViewCreated(View view,Bundle savedInstanceState) {
    final Resources res = getActivity().getResources();

    fab = (FloatingActionButton)view.findViewById(R.id.fab);
    fab.setonClickListener(this);
    if(isTelevision()){
        fab.setVisibility(View.GONE);
    }

    mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);
    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);
    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setonItemClickListener(mItemListener);
    if(isTelevision()) {
        mListView.setonItemLongClickListener(mItemLongClickListener);
    }
    fab.attachToListView(mListView);

    // Indent our list divider to align with text
    final Drawable divider = mListView.getDivider();
    final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
    final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
    if (insetLeft) {
        mListView.setDivider(new InsetDrawable(divider,insetSize,0));
    } else {
        mListView.setDivider(new InsetDrawable(divider,0));
    }
}
项目:grafika    文件ReadPixelsActivity.java   
@Override
protected void onPostExecute(Long result) {
    Log.d(TAG,"onPostExecute result=" + result);
    mDialog.dismiss();
    mDialog = null;

    Resources res = getResources();
    if (result < 0) {
        setMessage(mResultTextId,res.getString(R.string.did_not_complete));
    } else {
        setMessage(mResultTextId,(result / 1000) +
                res.getString(R.string.usec_per_iteration));
    }
}
项目:GitHub    文件GlideRequest.java   
/**
 * @see GlideOptions#theme(Resources.Theme)
 */
@CheckResult
public GlideRequest<TranscodeType> theme(@Nullable Resources.Theme arg0) {
  if (getMutableOptions() instanceof GlideOptions) {
    this.requestOptions = ((GlideOptions) getMutableOptions()).theme(arg0);
  } else {
    this.requestOptions = new GlideOptions().apply(this.requestOptions).theme(arg0);
  }
  return this;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。