List of usage examples for android.graphics.drawable Drawable setTint
public void setTint(@ColorInt int tintColor)
From source file:com.rks.musicx.ui.adapters.PlaylistListAdapter.java
@Override public void onBindViewHolder(PlaylistViewHolder holder, int position) { Playlist playlist = getItem(position); holder.PlaylistName.setText(playlist.getName()); Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlist.getId()); int songCount = PlaylistHelper.getSongCount(getContext().getContentResolver(), uri); holder.SongCount.setText(String.valueOf(songCount) + " " + getContext().getString(R.string.titles)); holder.deletePlaylist.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu)); Drawable drawable = holder.deletePlaylist.getDrawable(); drawable.mutate();/*from www . j a va 2 s . c om*/ if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) { drawable.setTint(Color.WHITE); holder.PlaylistName.setTextColor(Color.WHITE); holder.SongCount.setTextColor(Color.WHITE); } else { drawable.setTint(ContextCompat.getColor(getContext(), R.color.MaterialGrey)); holder.SongCount.setTextColor(ContextCompat.getColor(getContext(), R.color.MaterialGrey)); holder.PlaylistName.setTextColor(ContextCompat.getColor(getContext(), R.color.MaterialGrey)); } }
From source file:org.jak_linux.dns66.ItemActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();// ww w . j a v a2s . c om if (intent.getIntExtra("STATE_CHOICES", 3) == 2) { setContentView(R.layout.activity_item_dns); setTitle(R.string.activity_edit_dns_server); } else { setContentView(R.layout.activity_item); setTitle(R.string.activity_edit_filter); } titleText = (TextInputEditText) findViewById(R.id.title); locationText = (TextInputEditText) findViewById(R.id.location); stateSpinner = (Spinner) findViewById(R.id.state_spinner); stateSwitch = (Switch) findViewById(R.id.state_switch); imageView = (ImageView) findViewById(R.id.image_view); if (intent.hasExtra("ITEM_TITLE")) titleText.setText(intent.getStringExtra("ITEM_TITLE")); if (intent.hasExtra("ITEM_LOCATION")) locationText.setText(intent.getStringExtra("ITEM_LOCATION")); if (intent.hasExtra("ITEM_STATE") && stateSpinner != null) stateSpinner.setSelection(intent.getIntExtra("ITEM_STATE", 0)); if (intent.hasExtra("ITEM_STATE") && stateSwitch != null) stateSwitch.setChecked(intent.getIntExtra("ITEM_STATE", 0) % 2 != 0); if (stateSpinner != null) { stateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case Configuration.Item.STATE_ALLOW: imageView.setImageDrawable( ContextCompat.getDrawable(ItemActivity.this, R.drawable.ic_state_allow)); break; case Configuration.Item.STATE_DENY: imageView.setImageDrawable( ContextCompat.getDrawable(ItemActivity.this, R.drawable.ic_state_deny)); break; case Configuration.Item.STATE_IGNORE: imageView.setImageDrawable( ContextCompat.getDrawable(ItemActivity.this, R.drawable.ic_state_ignore)); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } // We have an attachment icon for host files if (intent.getIntExtra("STATE_CHOICES", 3) == 3) { locationText.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { boolean isAttachIcon; if (locationText.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR) isAttachIcon = event.getRawX() >= locationText.getRight() - locationText.getTotalPaddingRight(); else isAttachIcon = event.getRawX() <= locationText.getTotalPaddingLeft() - locationText.getLeft(); if (isAttachIcon) { performFileSearch(); return true; } } return false; } }); // Tint the attachment icon, if any. TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(android.R.attr.textColorPrimary, typedValue, true); Drawable[] compoundDrawables = locationText.getCompoundDrawablesRelative(); for (Drawable drawable : compoundDrawables) { if (drawable != null) { drawable.setTint(ContextCompat.getColor(this, typedValue.resourceId)); Log.d(TAG, "onCreate: Setting tint"); } } } }
From source file:com.rks.musicx.ui.adapters.SongListAdapter.java
@Override public void onBindViewHolder(SongListAdapter.SongViewHolder holder, int position) { Song song = getItem(position);/*from ww w . j a v a2 s .c om*/ if (layout == R.layout.song_list) { holder.SongTitle.setText(song.getTitle()); holder.SongArtist.setText(song.getArtist()); ArtworkUtils.ArtworkLoader(getContext(), 300, 600, song.getAlbum(), song.getAlbumId(), new palette() { @Override public void palettework(Palette palette) { } }, holder.SongArtwork); holder.menu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu)); Drawable drawable = holder.menu.getDrawable(); int accentColor = Config.accentColor(getContext(), Helper.getATEKey(getContext())); if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) { drawable.setTint(Color.WHITE); holder.SongTitle.setTextColor(Color.WHITE); holder.SongArtist.setTextColor(ContextCompat.getColor(getContext(), R.color.darkthemeTextColor)); holder.itemView.setBackgroundColor(storeChecked.get(position) ? ContextCompat.getColor(getContext(), R.color.translucent_white_8p) : Color.TRANSPARENT); } else { drawable.setTint(ContextCompat.getColor(getContext(), R.color.MaterialGrey)); holder.SongTitle.setTextColor(Color.BLACK); holder.SongArtist.setTextColor(Color.DKGRAY); holder.itemView .setBackgroundColor(storeChecked.get(position) ? Helper.getColorWithAplha(accentColor, 0.7f) : Color.TRANSPARENT); } } if (layout == R.layout.detail_list) { holder.SongTitle.setText(song.getTitle()); holder.SongArtist.setText(song.getArtist()); holder.number.setText(position + 1 + "."); holder.menu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu)); Drawable drawable = holder.menu.getDrawable(); if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) { drawable.setTint(Color.WHITE); holder.SongTitle.setTextColor(Color.WHITE); holder.number.setTextColor(Color.WHITE); holder.SongArtist.setTextColor(ContextCompat.getColor(getContext(), R.color.darkthemeTextColor)); } else { drawable.setTint(ContextCompat.getColor(getContext(), R.color.MaterialGrey)); holder.SongTitle.setTextColor(Color.BLACK); holder.number.setTextColor(Color.BLACK); holder.SongArtist.setTextColor(Color.DKGRAY); } } if (layout == R.layout.item_grid_view || layout == R.layout.recent_list) { int pos = holder.getAdapterPosition(); if (lastpos < pos) { for (Animator animator : getAnimator(holder.songView)) { animator.setDuration(duration); animator.setInterpolator(interpolator); animator.start(); } } holder.SongTitle.setText(song.getTitle()); holder.SongArtist.setText(song.getArtist()); ArtworkUtils.ArtworkLoader(getContext(), 300, 600, song.getAlbum(), song.getAlbumId(), new palette() { @Override public void palettework(Palette palette) { final int[] colors = Helper.getAvailableColor(getContext(), palette); holder.songView.setBackgroundColor(colors[0]); holder.SongTitle.setTextColor(Helper.getTitleTextColor(colors[0])); holder.SongArtist.setTextColor(Helper.getTitleTextColor(colors[0])); Helper.animateViews(getContext(), holder.itemView, colors[0]); } }, holder.songGridArtwork); holder.menu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu)); holder.menu.setVisibility(View.VISIBLE); Drawable drawable = holder.menu.getDrawable(); if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) { drawable.setTint(Color.WHITE); } } }
From source file:com.rks.musicx.ui.adapters.FolderAdapter.java
@Override public void onBindViewHolder(FolderAdapter.Folderviewholder holder, int position) { Folder folder = getItem(position);/*from w ww. ja va 2 s. co m*/ holder.filename.setTypeface(Helper.getFont(getContext())); holder.extraParam.setTypeface(Helper.getFont(getContext())); holder.menu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu)); Drawable drawable = holder.menu.getDrawable(); int accentColor = Config.accentColor(getContext(), Helper.getATEKey(getContext())); if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) { holder.filename.setTextColor(Color.WHITE); drawable.setTint(Color.WHITE); holder.extraParam.setTextColor(Color.WHITE); } else { holder.filename.setTextColor(Color.BLACK); holder.extraParam.setTextColor(Color.BLACK); drawable.setTint(ContextCompat.getColor(getContext(), R.color.MaterialGrey)); } if (folder.getFile().isDirectory()) { Glide.with(getContext()).load(R.drawable.folder).diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true).crossFade().placeholder(R.drawable.folder).error(R.drawable.folder) .into(holder.thumbnail); holder.thumbnail.setBorderColor(Color.TRANSPARENT); holder.thumbnail.setBorderWidth(0); int count = folder.getFileCount(); if (count == 0) { holder.extraParam.setVisibility(View.GONE); } else { holder.extraParam.setText(String.valueOf(folder.getFileCount()) + " files"); } if (position == 0) { holder.filename.setText(".."); holder.menu.setVisibility(View.GONE); } else { holder.filename.setText(folder.getFile().getName()); holder.menu.setVisibility(View.VISIBLE); } } else { songList = folder.getSongList(); if (songList.size() > 0) { String currentPath = folder.getFile().getAbsolutePath(); int index = Helper.getIndex(currentPath, songList); if (index > -1) { Song song = songList.get(index); holder.filename.setText(song.getTitle()); holder.extraParam.setText(song.getArtist()); holder.extraParam.setVisibility(View.VISIBLE); ArtworkUtils.ArtworkLoader(getContext(), 300, 600, song.getAlbum(), song.getAlbumId(), new palette() { @Override public void palettework(Palette palette) { } }, holder.thumbnail); if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) { holder.itemView.setBackgroundColor(storeChecked.get(index) ? ContextCompat.getColor(getContext(), R.color.translucent_white_8p) : Color.TRANSPARENT); } else { holder.itemView.setBackgroundColor( storeChecked.get(index) ? Helper.getColorWithAplha(accentColor, 0.7f) : Color.TRANSPARENT); } } } } }
From source file:com.rks.musicx.ui.fragments.PlayingViews.Playing4Fragment.java
@Override protected void function() { ateKey = Helper.getATEKey(getContext()); accentColor = Config.accentColor(getContext(), ateKey); primaryColor = Config.primaryColor(getContext(), ateKey); playpausebutton.setOnClickListener(onClick); Drawable bg = ContextCompat.getDrawable(getContext(), R.drawable.transparent); if (seekbar != null) { seekbar.setSplitTrack(false);/*from w ww . jav a 2 s.c o m*/ if (seekbar.getThumb() != null) { seekbar.getThumb().mutate().setAlpha(0); } seekbar.setBackground(bg); } favButton.setOnClickListener(onClick); queueClick.setOnClickListener(onClick); moreMenu.setOnClickListener(onClick); favhelper = new FavHelper(getContext()); moreMenu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu)); shuffleButton.setOnClickListener(onClick); shuffleButton.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.shuf_off)); repeatButton.setOnClickListener(onClick); repeatButton.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.rep_no)); playpausebutton.setOnClickListener(onClick); next.setOnClickListener(onClick); prev.setOnClickListener(onClick); CustomLayoutManager customlayoutmanager = new CustomLayoutManager(getActivity()); customlayoutmanager.setOrientation(LinearLayoutManager.VERTICAL); customlayoutmanager.setSmoothScrollbarEnabled(true); queuerv.setLayoutManager(customlayoutmanager); queuerv.addItemDecoration(new DividerItemDecoration(getContext(), 75, true)); queuerv.setHasFixedSize(true); queueAdapter = new QueueAdapter(getContext(), this); queueAdapter.setLayoutId(R.layout.song_list); queuerv.setAdapter(queueAdapter); queueAdapter.setOnItemClickListener(mOnClick); ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(queueAdapter); mItemTouchHelper = new ItemTouchHelper(callback); mItemTouchHelper.attachToRecyclerView(queuerv); if (getActivity() == null && getActivity().getWindow() == null) { return; } getActivity().getWindow().setStatusBarColor(accentColor); initVisualizer(); helper = new Helper(getContext()); Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_queue); drawable.setTint(Color.WHITE); queueClick.setImageDrawable(drawable); }
From source file:com.android.mms.ui.MessageListItem.java
private void tintBackground(Drawable background, int color) { if (background instanceof LayerDrawable) { Drawable base = ((LayerDrawable) background).findDrawableByLayerId(R.id.base_layer); if (base instanceof StateListDrawable) { StateListDrawable sld = (StateListDrawable) base; base = sld.getStateDrawable(sld.getStateDrawableIndex(null)); }//from w w w . j a va 2 s . c o m if (base != null) { base.setTint(color); } } }