List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTintList
public static void setTintList(Drawable drawable, ColorStateList colorStateList)
From source file:despotoski.nikola.github.com.bottomnavigationlayout.BottomTabletNavigationView.java
private void applyColorFilters() { if (isSelected()) { DrawableCompat.setTint(mTopDrawable, mTextActiveColorFilter); } else {/* w w w. ja v a2 s .co m*/ DrawableCompat.setTintList(mTopDrawable, null); } }
From source file:com.bilibili.magicasakura.widgets.AppCompatForegroundHelper.java
private boolean applySupportForegroundTint() { Drawable foregroundDrawable = getForeground(); if (foregroundDrawable != null && mForegroundTintInfo != null && mForegroundTintInfo.mHasTintList) { foregroundDrawable = DrawableCompat.wrap(foregroundDrawable); foregroundDrawable = foregroundDrawable.mutate(); if (mForegroundTintInfo.mHasTintList) { DrawableCompat.setTintList(foregroundDrawable, mForegroundTintInfo.mTintList); }/* www. ja va 2s . c om*/ if (mForegroundTintInfo.mHasTintMode) { DrawableCompat.setTintMode(foregroundDrawable, mForegroundTintInfo.mTintMode); } if (foregroundDrawable.isStateful()) { foregroundDrawable.setState(mView.getDrawableState()); } setForegroundDrawable(foregroundDrawable); return true; } return false; }
From source file:jp.tkgktyk.xposed.forcetouchdetector.app.util.fab.FloatingActionButtonEclairMr1.java
@Override void setRippleColor(int rippleColor) { DrawableCompat.setTintList(mRippleDrawable, createColorStateList(rippleColor)); }
From source file:com.bilibili.magicasakura.widgets.AppCompatCompoundButtonHelper.java
public boolean applySupportButtonDrawableTint() { Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable((CompoundButton) mView); if (buttonDrawable != null && mCompoundButtonTintInfo != null && mCompoundButtonTintInfo.mHasTintList) { buttonDrawable = DrawableCompat.wrap(buttonDrawable); buttonDrawable = buttonDrawable.mutate(); if (mCompoundButtonTintInfo.mHasTintList) { DrawableCompat.setTintList(buttonDrawable, mCompoundButtonTintInfo.mTintList); }//w w w . j av a2 s.c o m if (mCompoundButtonTintInfo.mHasTintMode) { DrawableCompat.setTintMode(buttonDrawable, mCompoundButtonTintInfo.mTintMode); } // The drawable (or one of its children) may not have been // stateful before applying the tint, so let's try again. if (buttonDrawable.isStateful()) { buttonDrawable.setState(mView.getDrawableState()); } setButtonDrawable(buttonDrawable); return true; } return false; }
From source file:com.bilibili.magicasakura.widgets.AppCompatBackgroundHelper.java
private boolean applySupportBackgroundTint() { Drawable backgroundDrawable = mView.getBackground(); if (backgroundDrawable != null && mBackgroundTintInfo != null && mBackgroundTintInfo.mHasTintList) { backgroundDrawable = DrawableCompat.wrap(backgroundDrawable); backgroundDrawable = backgroundDrawable.mutate(); if (mBackgroundTintInfo.mHasTintList) { DrawableCompat.setTintList(backgroundDrawable, mBackgroundTintInfo.mTintList); }//from w w w. ja v a2s .c om if (mBackgroundTintInfo.mHasTintMode) { DrawableCompat.setTintMode(backgroundDrawable, mBackgroundTintInfo.mTintMode); } if (backgroundDrawable.isStateful()) { backgroundDrawable.setState(mView.getDrawableState()); } setBackgroundDrawable(backgroundDrawable); return true; } return false; }
From source file:com.alainesp.fan.sanderson.MainActivity.java
/** * Set the badge number to all menu items visible *//*from w ww. j a va 2 s .c om*/ private static void setBadgesNumberUI() { if (navigationView != null) { NavigationMenuView v = (NavigationMenuView) navigationView.getChildAt(0); Menu drawerMenu = navigationView.getMenu(); if (v != null) // Iterate all children for (int childIndex = 0; childIndex < v.getChildCount(); childIndex++) { View v1 = v.getChildAt(childIndex); if (v1 instanceof NavigationMenuItemView) { TextView mTextView = (TextView) ((NavigationMenuItemView) v1).getChildAt(0); if (mTextView != null) { // Get the menu index Integer menuIndex = reverseMenuText.get(mTextView.getText().toString()); if (menuIndex != null && menuIndex < badgeNumbers.length) { Drawable numberText = null; if (badgeNumbers[menuIndex] > 0) { int height = mTextView.getHeight(); numberText = new TextDrawable(badgeNumbers[menuIndex], mTextView.getTextSize(), mTextView.getCurrentTextColor(), height); numberText.setBounds(0, 0, height, height); } // Similar to NavigationMenuItemView.setIcon Drawable icon = drawerMenu.getItem(menuIndex).getIcon(); Drawable.ConstantState state = icon.getConstantState(); icon = DrawableCompat.wrap(state == null ? icon : state.newDrawable()).mutate(); int mIconSize = navigationView.getContext().getResources().getDimensionPixelSize( android.support.design.R.dimen.design_navigation_icon_size); icon.setBounds(0, 0, mIconSize, mIconSize); DrawableCompat.setTintList(icon, navigationView.getItemIconTintList()); TextViewCompat.setCompoundDrawablesRelative(mTextView, icon, null, numberText, null); } } } } } }
From source file:com.owncloud.android.ui.activity.FingerprintActivity.java
private void startFingerprint() { TextView fingerprintTextView = (TextView) findViewById(R.id.scanfingerprinttext); FingerprintManager fingerprintManager = (FingerprintManager) MainApp.getAppContext() .getSystemService(Context.FINGERPRINT_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return;//from w w w . j a v a2 s .com } KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); if (!keyguardManager.isKeyguardSecure()) { return; } else { generateKey(); if (cipherInit()) { cryptoObject = new FingerprintManager.CryptoObject(cipher); FingerprintHandler.Callback callback = new FingerprintHandler.Callback() { @Override public void onAuthenticated() { fingerprintResult(true); } @Override public void onFailed(String error) { Toast.makeText(MainApp.getAppContext(), error, Toast.LENGTH_LONG).show(); ImageView imageView = (ImageView) findViewById(R.id.fingerprinticon); int[][] states = new int[][] { new int[] { android.R.attr.state_activated }, new int[] { -android.R.attr.state_activated } }; int[] colors = new int[] { Color.parseColor("#FF0000"), Color.RED }; ColorStateList csl = new ColorStateList(states, colors); Drawable drawable = DrawableCompat.wrap(imageView.getDrawable()); DrawableCompat.setTintList(drawable, csl); imageView.setImageDrawable(drawable); } }; helper = new FingerprintHandler(fingerprintTextView, callback); cancellationSignal = new CancellationSignal(); if (ActivityCompat.checkSelfPermission(MainApp.getAppContext(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { return; } fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, helper, null); } } }
From source file:com.facebook.react.views.slider.ReactSlider.java
@TargetApi(21) public void setProgressColor(Integer value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setProgressTintList(ColorStateList.valueOf(value)); } else {//from w w w . j av a 2 s . c o m if (getProgressDrawable() instanceof LayerDrawable) { LayerDrawable layer = (LayerDrawable) getProgressDrawable(); DrawableCompat.setTintList(layer.findDrawableByLayerId(android.R.id.progress).mutate(), ColorStateList.valueOf(value)); } } }
From source file:com.wanderingcan.persistentsearch.SearchMenuItem.java
/** * Sets the drawable for the icon for the SearchMenuItem * @param icon The drawable for the icon *///from www . j a va 2 s . co m public SearchMenuItem setIcon(Drawable icon) { mIconDrawable = DrawableCompat.wrap(icon); if (mIconTint != null) { DrawableCompat.setTintList(mIconDrawable, mIconTint); } if (mIconTintMode != null) { DrawableCompat.setTintMode(mIconDrawable, mIconTintMode); } notifyItemChanged(); return this; }
From source file:com.guoxiaoxing.cloud.music.magicasakura.widgets.AppCompatImageHelper.java
private boolean applySupportImageTint() { Drawable image = ((ImageView) mView).getDrawable(); AnimationDrawable animationDrawable = null; if (image instanceof AnimationDrawable) { Log.e("drawable", "is animationdrawable"); animationDrawable = ((AnimationDrawable) image); //image = animationDrawable; }//from w w w . j a v a 2 s . c o m if (image != null && mImageTintInfo != null && mImageTintInfo.mHasTintList) { if (animationDrawable != null) { Log.e("drawable", "is animationdrawable not null"); Drawable tintDrawable = animationDrawable; Log.e("drawable", "start0"); tintDrawable = DrawableCompat.wrap(tintDrawable); Log.e("drawable", "start1"); if (mImageTintInfo.mHasTintList) { DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList); } if (mImageTintInfo.mHasTintMode) { DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode); } if (tintDrawable.isStateful()) { tintDrawable.setState(mView.getDrawableState()); } tintDrawable = DrawableCompat.unwrap(tintDrawable); setImageDrawable(tintDrawable); if (image == tintDrawable) { Log.e("drawable", "invalidateself"); // tintDrawable.invalidateSelf(); } return true; } else { Drawable tintDrawable = image.mutate(); tintDrawable = DrawableCompat.wrap(tintDrawable); if (mImageTintInfo.mHasTintList) { DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList); } if (mImageTintInfo.mHasTintMode) { DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode); } if (tintDrawable.isStateful()) { tintDrawable.setState(mView.getDrawableState()); } setImageDrawable(tintDrawable); if (image == tintDrawable) { tintDrawable.invalidateSelf(); } return true; } } return false; }