List of usage examples for android.support.v4.content ContextCompat getDrawable
public static final Drawable getDrawable(Context context, int i)
From source file:com.filemanager.free.ui.icons.IconUtils.java
public Drawable getSdDrawable() { if (CURRENT == LIGHT) return ContextCompat.getDrawable(c, R.drawable.ic_sd_storage_white_56dp); else//from w ww . j a v a 2s.c om return ContextCompat.getDrawable(c, R.drawable.ic_sd_storage_white_56dp); }
From source file:com.dbeginc.dbweather.utils.animations.widgets.RainFallView.java
public RainFallView(Context context) { super(context); setFocusable(true);// w w w . j a va2s .c o m setFocusableInTouchMode(true); this.setId(VIEW_ID); mRainDrop = ContextCompat.getDrawable(context, R.drawable.raindrop); mRainDrop.setBounds(0, 0, mRainDrop.getIntrinsicWidth(), mRainDrop.getIntrinsicHeight()); }
From source file:com.dbeginc.dbweather.utils.animations.widgets.SnowFallView.java
public SnowFallView(Context context) { super(context); setFocusable(true);// w w w . j av a2 s . c o m setFocusableInTouchMode(true); this.setId(VIEW_ID); snow_flake = ContextCompat.getDrawable(context, R.drawable.snow_fall); snow_flake.setBounds(0, 0, snow_flake.getIntrinsicWidth(), snow_flake.getIntrinsicHeight()); }
From source file:com.freshdigitable.udonroad.MediaImageView.java
public MediaImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setContentDescription(getResources().getString(R.string.tweet_media_descs)); setVisibility(GONE);//from ww w . jav a2s.c o m if (playIcon == null) { final Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ld_play_icon); playIcon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(playIcon); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); } }
From source file:com.asc_ii.bangnote.bigbang.BigBangActionBar.java
private void initSubViews() { Context context = getContext(); mBorder = ContextCompat.getDrawable(context, R.drawable.bigbang_action_bar_bg); mBorder.setCallback(this); mSearch = new ImageView(context); mSearch.setImageResource(R.mipmap.bigbang_action_search); mSearch.setOnClickListener(this); mShare = new ImageView(context); mShare.setImageResource(R.mipmap.bigbang_action_share); mShare.setOnClickListener(this); mCopy = new ImageView(context); mCopy.setImageResource(R.mipmap.bigbang_action_copy); mCopy.setOnClickListener(this); addView(mSearch, createLayoutParams()); addView(mShare, createLayoutParams()); addView(mCopy, createLayoutParams()); setWillNotDraw(false);/*w ww. j ava 2 s . c om*/ mActionGap = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, getResources().getDisplayMetrics()); mContentPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()); }
From source file:am.project.x.business.drawables.lineardrawable.LinearDrawableActivity.java
@Override protected void initializeActivity(@Nullable Bundle savedInstanceState) { setSupportActionBar(R.id.lrd_toolbar); drawable = new LinearDrawable(ContextCompat.getDrawable(this, R.drawable.ic_drawableratingbar_selected)); drawable.setCount(1);/*from w w w .j ava 2s. co m*/ density = getResources().getDisplayMetrics().density; this.<ImageView>findViewById(R.id.lrd_iv_content).setImageDrawable(drawable); this.<Switch>findViewById(R.id.lrd_sh_orientation).setOnCheckedChangeListener(this); this.<SeekBar>findViewById(R.id.lrd_sb_number).setOnSeekBarChangeListener(this); this.<SeekBar>findViewById(R.id.lrd_sb_gap).setOnSeekBarChangeListener(this); }
From source file:com.example.android.materialme.DetailActivity.java
/** * Initializes the activity, filling in the data from the Intent. * @param savedInstanceState Contains information about the saved state of the activity */// w w w .j a v a 2 s . c o m @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); //Initialize the views TextView sportsTitle = (TextView) findViewById(R.id.titleDetail); ImageView sportsImage = (ImageView) findViewById(R.id.sportsImageDetail); //Get the drawable Drawable drawable = ContextCompat.getDrawable(this, getIntent().getIntExtra(Sport.IMAGE_KEY, 0)); //Create a placeholder gray scrim while the image loads GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setColor(Color.GRAY); //Make it the same size as the image if (drawable != null) { gradientDrawable.setSize(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); } //Set the text from the Intent extra sportsTitle.setText(getIntent().getStringExtra(Sport.TITLE_KEY)); //Load the image using the glide library and the Intent extra Glide.with(this).load(getIntent().getIntExtra(Sport.IMAGE_KEY, 0)).placeholder(gradientDrawable) .into(sportsImage); }
From source file:com.example.ray.firstapp.bottombar.BottomBarItemBase.java
protected Drawable getIcon(Context context) { if (this.iconResource != 0) { return ContextCompat.getDrawable(context, this.iconResource); } else {// w w w . j a va 2s . c o m return this.icon; } }
From source file:com.google.samples.apps.ourstreets.map.DetailMarkerRenderer.java
public DetailMarkerRenderer(Context context, final GoogleMap map, final ClusterManager<Detail> clusterManager) { super(context, map, clusterManager); mMarkerDrawable = ContextCompat.getDrawable(context, R.drawable.map_pin); map.setInfoWindowAdapter(clusterManager.getMarkerManager()); }
From source file:com.hackedcube.blenderopenmovies.CardPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { Log.d(TAG, "onCreateViewHolder"); sDefaultBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.default_background); sSelectedBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.selected_background); mDefaultCardImage = ContextCompat.getDrawable(parent.getContext(), R.drawable.movie); ImageCardView cardView = new ImageCardView(parent.getContext()) { @Override//from w w w.j av a 2 s . c o m public void setSelected(boolean selected) { updateCardBackgroundColor(this, selected); super.setSelected(selected); } }; cardView.setFocusable(true); cardView.setFocusableInTouchMode(true); updateCardBackgroundColor(cardView, false); return new ViewHolder(cardView); }