List of usage examples for android.support.v4.content ContextCompat getDrawable
public static final Drawable getDrawable(Context context, int i)
From source file:com.example.gatsu.theevent.HighlightView.java
private void init() { mResizeDrawableWidth = ContextCompat.getDrawable(mContext.getContext(), R.drawable.camera_crop_width); mResizeDrawableHeight = ContextCompat.getDrawable(mContext.getContext(), R.drawable.camera_crop_height); mResizeDrawableDiagonal = ContextCompat.getDrawable(mContext.getContext(), R.drawable.indicator_autocrop); }
From source file:am.project.x.business.others.printer.PrinterBluetoothDialog.java
PrinterBluetoothDialog(@NonNull Context context, @NonNull OnDialogListener listener) { super(context, AlertDialogUtils.getAlertDialogTheme(context)); mListener = listener;/*from ww w . j a v a 2s.com*/ setContentView(R.layout.dlg_printer_bluetooth); final RecyclerView bonded = findViewById(R.id.dpb_rv_bonded); if (bonded == null) return; final Drawable divider = ContextCompat.getDrawable(context, R.drawable.divider_common); if (divider != null) { final DividerItemDecoration decoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL); decoration.setDrawable(divider); bonded.addItemDecoration(decoration); } bonded.setLayoutManager(new LinearLayoutManager(context)); bonded.setAdapter(mAdapter); }
From source file:cn.finalteam.galleryfinal.adapter.CommonBaseAdapter.java
protected Drawable createCheckIcon(int color, int resId) { Drawable checkIcon = ContextCompat.getDrawable(mActivity, resId); checkIcon = DrawableCompat.wrap(checkIcon); DrawableCompat.setTint(checkIcon, color); return checkIcon; }
From source file:am.project.x.business.drawables.combinationdrawable.CombinationDrawableActivity.java
@Override protected void initializeActivity(@Nullable Bundle savedInstanceState) { setSupportActionBar(R.id.cod_toolbar); drawable = new CombinationDrawable(ContextCompat.getDrawable(this, R.drawable.bg_combinationdrawable_item), ContextCompat.getDrawable(this, R.drawable.ic_drawables_drawable)); this.<ImageView>findViewById(R.id.cod_iv_image).setImageDrawable(drawable); this.<Spinner>findViewById(R.id.cod_sp_gravity).setOnItemSelectedListener(this); this.<SeekBar>findViewById(R.id.cod_sb_width).setOnSeekBarChangeListener(this); }
From source file:com.jameswolfeoliver.pigeon.Utilities.DrawableHelper.java
public DrawableHelper withDrawable(@DrawableRes int drawableRes) { mDrawable = ContextCompat.getDrawable(mContext, drawableRes); return this; }
From source file:com.amazon.android.tv.tenfoot.presenter.SettingsCardPresenter.java
/** * {@inheritDoc}/* w w w . j a va2 s . c o m*/ */ @Override public ViewHolder onCreateViewHolder(ViewGroup parent) { Context context = parent.getContext(); try { sFocusedFadeMask = ContextCompat.getDrawable(context, R.drawable.content_fade_focused); } catch (Resources.NotFoundException e) { Log.e(TAG, "Resource not found", e); throw e; } ImageCardView cardView = new ImageCardView(context) { @Override public void setSelected(boolean selected) { super.setSelected(selected); if (mInfoField != null) { mInfoField.setBackground(sFocusedFadeMask); } } }; cardView.setFocusable(true); cardView.setFocusableInTouchMode(true); // Set the type and visibility of the info area. cardView.setCardType(BaseCardView.CARD_TYPE_INFO_OVER); cardView.setInfoVisibility(BaseCardView.CARD_REGION_VISIBLE_ALWAYS); int CARD_WIDTH_PX = 160; mCardWidthDp = Helpers.convertPixelToDp(context, CARD_WIDTH_PX); int CARD_HEIGHT_PX = 120; mCardHeightDp = Helpers.convertPixelToDp(context, CARD_HEIGHT_PX); mInfoField = cardView.findViewById(R.id.info_field); if (mInfoField != null) { mInfoField.setBackground(sFocusedFadeMask); } return new ViewHolder(cardView); }
From source file:am.project.x.business.others.opentypelist.OpenTypeListActivity.java
@Override protected void initializeActivity(@Nullable Bundle savedInstanceState) { setSupportActionBar(R.id.otl_toolbar); final RecyclerView list = findViewById(R.id.otl_content); final Drawable divider = ContextCompat.getDrawable(this, R.drawable.divider_common); if (divider != null) { final DividerItemDecoration decoration = new DividerItemDecoration(list.getContext(), DividerItemDecoration.VERTICAL); decoration.setDrawable(divider); list.addItemDecoration(decoration); }//from www .j a v a 2 s . c om list.setAdapter(mAdapter); mPresenter.loadOpenType(); }
From source file:android.support.v7.app.MediaRouteExpandCollapseButton.java
public MediaRouteExpandCollapseButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mExpandAnimationDrawable = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.ic_expand); mCollapseAnimationDrawable = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.ic_collapse); ColorFilter filter = new PorterDuffColorFilter( MediaRouterThemeHelper.getControllerColor(context, defStyleAttr), PorterDuff.Mode.SRC_IN); mExpandAnimationDrawable.setColorFilter(filter); mCollapseAnimationDrawable.setColorFilter(filter); mExpandGroupDescription = context.getString(R.string.mr_controller_expand_group); mCollapseGroupDescription = context.getString(R.string.mr_controller_collapse_group); setImageDrawable(mExpandAnimationDrawable.getFrame(0)); setContentDescription(mExpandGroupDescription); super.setOnClickListener(new OnClickListener() { @Override/*from w ww. j av a 2s . co m*/ public void onClick(View view) { mIsGroupExpanded = !mIsGroupExpanded; if (mIsGroupExpanded) { setImageDrawable(mExpandAnimationDrawable); mExpandAnimationDrawable.start(); setContentDescription(mCollapseGroupDescription); } else { setImageDrawable(mCollapseAnimationDrawable); mCollapseAnimationDrawable.start(); setContentDescription(mExpandGroupDescription); } if (mListener != null) { mListener.onClick(view); } } }); }
From source file:com.example.ysh.myapplication.view.readview.TocListAdapter.java
@Override public void convert(EasyLVHolder holder, int position, BookMixAToc.mixToc.Chapters chapters) { TextView tvTocItem = holder.getView(R.id.tvTocItem); tvTocItem.setText(chapters.title);/* www . j av a 2 s. c om*/ Drawable drawable; if (currentChapter == position + 1) { tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_red)); drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_activated); } else if (isEpub || FileUtils.getChapterFile(bookId, position + 1).length() > 10) { tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_black)); drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_download); } else { tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_black)); drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_normal); } drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); tvTocItem.setCompoundDrawables(drawable, null, null, null); }
From source file:com.cleveroad.slidingtutorial.sample.renderer.DrawableRenderer.java
private DrawableRenderer(@NonNull Context context) { mDrawableActive = ContextCompat.getDrawable(context, R.drawable.vec_checkbox_fill_circle_outline); mDrawable = ContextCompat.getDrawable(context, R.drawable.vec_checkbox_blank_circle_outline); }