List of usage examples for android.support.v4.content.res ResourcesCompat getDrawableForDensity
public static Drawable getDrawableForDensity(Resources resources, int i, int i2, Theme theme) throws NotFoundException
From source file:com.dm.material.dashboard.candybar.helpers.DrawableHelper.java
@Nullable public static Bitmap getHighQualityIcon(@NonNull Context context, String packageName) { try {/* w w w. jav a2 s. co m*/ PackageManager packageManager = context.getPackageManager(); ApplicationInfo info = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA); Resources resources = packageManager.getResourcesForApplication(packageName); int density = DisplayMetrics.DENSITY_XXHIGH; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { density = DisplayMetrics.DENSITY_XXXHIGH; } Drawable drawable = ResourcesCompat.getDrawableForDensity(resources, info.icon, density, null); if (drawable != null) return ((BitmapDrawable) drawable).getBitmap(); } catch (Exception | OutOfMemoryError e) { LogUtil.e(Log.getStackTraceString(e)); } return null; }
From source file:com.hellofyc.base.app.adapter.BaseRecyclerViewAdapter.java
@Override public Drawable getDrawableForDensity(@DrawableRes int id, int density, @Nullable Resources.Theme theme) { return ResourcesCompat.getDrawableForDensity(getResources(), id, density, theme); }