List of usage examples for android.support.v4.content ContextCompat getDrawable
public static final Drawable getDrawable(Context context, int i)
From source file:Main.java
/** * Return a Drawable that contains an app icon for the named app. If not * found, return the Drawable for the GreenHub icon. * * @param appName/* w w w . ja v a 2 s . co m*/ * the application name * @return the Drawable for the application's icon */ public static Drawable iconForApp(final Context context, String appName) { try { return context.getPackageManager().getApplicationIcon(appName); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return ContextCompat.getDrawable(context, android.R.drawable.sym_def_app_icon); } }
From source file:com.fa.mastodon.util.ThemeUtils.java
public static Drawable getDrawable(Context context, @AttrRes int attribute, @DrawableRes int fallbackDrawable) { TypedValue value = new TypedValue(); @DrawableRes/*from ww w .j a v a2 s . co m*/ int resourceId; if (context.getTheme().resolveAttribute(attribute, value, true)) { resourceId = value.resourceId; } else { resourceId = fallbackDrawable; } return ContextCompat.getDrawable(context, resourceId); }
From source file:com.example.madiba.venu_alpha.utils.ColorUtils.java
public static Drawable colorDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId, Context context) {//from w w w . j ava 2 s. com Drawable drawable = ContextCompat.getDrawable(context, drawableResId); int color = res.getColor(colorResId); drawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN); return drawable; }
From source file:com.frostwire.android.offers.InHouseBannerFactory.java
public static void loadAd(final ImageView placeholder, AdFormat adFormat) { Message randomMessage = Message.random(); int randomDrawable = getRandomDrawable(adFormat, randomMessage); placeholder.setImageDrawable(ContextCompat.getDrawable(placeholder.getContext(), randomDrawable)); placeholder.setOnClickListener(CLICK_LISTENERS.get(randomMessage)); }
From source file:com.filemanager.free.ui.icons.IconUtils.java
public Drawable getCopyDrawable() { return ContextCompat.getDrawable(c, R.drawable.ic_content_copy_white_36dp); }
From source file:com.doctoror.particlesdrawable.demo.DemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { mDrawable = (ParticlesDrawable) ContextCompat.getDrawable(this, R.drawable.particles_customized); } else {/*from ww w .j av a 2s .c o m*/ mDrawable = new ParticlesDrawable(); } findViewById(android.R.id.content).setBackgroundDrawable(mDrawable); }
From source file:com.google.android.apps.santatracker.map.cardstream.SeparatorDecoration.java
public SeparatorDecoration(Context context) { mDrawable = ContextCompat.getDrawable(context, R.drawable.stream_separator); mHeight = context.getResources().getDimensionPixelSize(R.dimen.separator_height); }
From source file:com.filemanager.free.ui.icons.IconUtils.java
public Drawable getCutDrawable() { return ContextCompat.getDrawable(c, R.drawable.ic_content_cut_white_36dp); }
From source file:com.cesards.samples.cropimageview.activity.SimpleCropActivity.java
@Override protected ImageView instantiatePagerItem(int position) { ForegroundCropImageView testForegroundImageView = new ForegroundCropImageView(SimpleCropActivity.this); testForegroundImageView.setImageDrawable(ContextCompat.getDrawable(this, images[position])); testForegroundImageView/*from w w w . j a va 2 s. c o m*/ .setForeground(ContextCompat.getDrawable(this, R.drawable.shape_grad_black_transp_70)); testForegroundImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); return testForegroundImageView; }
From source file:com.anysoftkeyboard.keyboards.views.DrawableBuilder.java
@Nullable public Drawable buildDrawable() { final Context packageContext = mTheme.getPackageContext(); if (packageContext == null) return null; return ContextCompat.getDrawable(packageContext, mDrawableResourceId); }