List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTintMode
public static void setTintMode(Drawable drawable, Mode mode)
From source file:com.commonsware.cwac.crossport.design.widget.FloatingActionButtonImpl.java
void setBackgroundDrawable(ColorStateList backgroundTint, PorterDuff.Mode backgroundTintMode, int rippleColor, int borderWidth) { // Now we need to tint the original background with the tint, using // an InsetDrawable if we have a border width mShapeDrawable = DrawableCompat.wrap(createShapeDrawable()); DrawableCompat.setTintList(mShapeDrawable, backgroundTint); if (backgroundTintMode != null) { DrawableCompat.setTintMode(mShapeDrawable, backgroundTintMode); }/*from www .j a v a 2 s . c o m*/ // Now we created a mask Drawable which will be used for touch feedback. GradientDrawable touchFeedbackShape = createShapeDrawable(); // We'll now wrap that touch feedback mask drawable with a ColorStateList. We do not need // to inset for any border here as LayerDrawable will nest the padding for us mRippleDrawable = DrawableCompat.wrap(touchFeedbackShape); DrawableCompat.setTintList(mRippleDrawable, createColorStateList(rippleColor)); final Drawable[] layers; if (borderWidth > 0) { mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint); layers = new Drawable[] { mBorderDrawable, mShapeDrawable, mRippleDrawable }; } else { mBorderDrawable = null; layers = new Drawable[] { mShapeDrawable, mRippleDrawable }; } mContentBackground = new LayerDrawable(layers); mShadowDrawable = new ShadowDrawableWrapper(mView.getContext(), mContentBackground, mShadowViewDelegate.getRadius(), mElevation, mElevation + mPressedTranslationZ); mShadowDrawable.setAddPaddingForCorners(false); mShadowViewDelegate.setBackgroundDrawable(mShadowDrawable); }
From source file:android.support.v7.graphics.drawable.DrawableWrapper.java
@Override public void setTintMode(PorterDuff.Mode tintMode) { DrawableCompat.setTintMode(mDrawable, tintMode); }
From source file:com.negusoft.greenmatter.drawable.CompoundDrawableWrapper.java
@Override public void setTintMode(PorterDuff.Mode tintMode) { for (Drawable d : mSecondaryDrawables) DrawableCompat.setTintMode(d, tintMode); super.setTintMode(tintMode); }
From source file:jp.tkgktyk.xposed.forcetouchdetector.app.util.fab.FloatingActionButtonEclairMr1.java
@Override void setBackgroundTintMode(PorterDuff.Mode tintMode) { DrawableCompat.setTintMode(mShapeDrawable, tintMode); }
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); }/* w w w .j a va 2s . c o m*/ if (mForegroundTintInfo.mHasTintMode) { DrawableCompat.setTintMode(foregroundDrawable, mForegroundTintInfo.mTintMode); } if (foregroundDrawable.isStateful()) { foregroundDrawable.setState(mView.getDrawableState()); } setForegroundDrawable(foregroundDrawable); return true; } return false; }
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 . ja v a2 s.c om*/ 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:jahirfiquitiva.iconshowcase.utilities.color.ColorUtils.java
@CheckResult @Nullable/*from ww w .ja v a2 s . c o m*/ public static Drawable getTintedIcon(Drawable drawable, int color) { if (drawable != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (drawable instanceof VectorDrawable) { drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN); } drawable = DrawableCompat.wrap(drawable.mutate()); } else { drawable = DrawableCompat.wrap(drawable); } DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN); DrawableCompat.setTint(drawable, color); return drawable; } else { return null; } }
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); }/* w w w.jav a 2 s. c o m*/ if (mBackgroundTintInfo.mHasTintMode) { DrawableCompat.setTintMode(backgroundDrawable, mBackgroundTintInfo.mTintMode); } if (backgroundDrawable.isStateful()) { backgroundDrawable.setState(mView.getDrawableState()); } setBackgroundDrawable(backgroundDrawable); return true; } return false; }
From source file:galilei.kelimekavanozu.activity.ThemeChooserActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Accelerometer check PackageManager manager = getPackageManager(); hasAccelerometer = manager.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER); setContentView(R.layout.activity_theme_chooser); SugarContext.init(this); arkaplan500 = (ImageView) findViewById(R.id.arkaplan500); kavanoz = (ImageView) findViewById(R.id.cannonball_logo); recyclerView = (RecyclerView) findViewById(R.id.main_list); final Animation shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.shake); fab = (FloatingActionButton) findViewById(R.id.fab); StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); gridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS); recyclerView.setLayoutManager(gridLayoutManager); initialCount = Note.count(Note.class); if (savedInstanceState != null) modifyPos = savedInstanceState.getInt("modify"); if (initialCount >= 0) { notes = Note.listAll(Note.class); adapter = new KelimelerAdapter(ThemeChooserActivity.this, notes); recyclerView.setAdapter(adapter); }/*w w w .jav a 2s. co m*/ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_add_24dp); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, Color.WHITE); DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN); fab.setImageDrawable(drawable); } fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Crashlytics.log("Yeni Kelime: butona basld"); // Answers.getInstance().logCustom(new CustomEvent("Ekle butonuna basld")); Intent i = new Intent(ThemeChooserActivity.this, AddNoteActivity.class); startActivity(i); } }); if (isNetworkConnected()) { new arkaplan().execute(); } // Handling swipe to delete setUpViews(); ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) { @Override public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { return false; } @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { //Remove swiped item from list and notify the RecyclerView final int position = viewHolder.getAdapterPosition(); final Note note = notes.get(viewHolder.getAdapterPosition()); notes.remove(viewHolder.getAdapterPosition()); adapter.notifyItemRemoved(position); note.delete(); initialCount -= 1; Snackbar.make(fab, "Kelime silindi", Snackbar.LENGTH_SHORT) .setAction("GER AL", new View.OnClickListener() { @Override public void onClick(View v) { note.save(); notes.add(position, note); adapter.notifyItemInserted(position); initialCount += 1; } }).show(); } }; ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleCallback); itemTouchHelper.attachToRecyclerView(recyclerView); adapter.SetOnItemClickListener(new KelimelerAdapter.OnItemClickListener() { @Override public void onItemClick(View view, int position) { Log.d("Main", "click"); Intent i = new Intent(ThemeChooserActivity.this, AddNoteActivity.class); i.putExtra("isEditing", true); i.putExtra("note_title", notes.get(position).title); i.putExtra("note", notes.get(position).note); i.putExtra("note_time", notes.get(position).time); modifyPos = position; startActivity(i); } }); if (hasAccelerometer) { kavanoz.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // View element to be shaken // Perform animation if (notclick) { kavanoz.startAnimation(shake); shakemode = true; notclick = false; Snackbar.make(fab, "Rastgele kelimelerden birini grmek iin telefonunuzu sallayn.", Snackbar.LENGTH_LONG).show(); kavanoz.setColorFilter(Color.argb(100, 255, 140, 0)); } else { shakemode = false; notclick = true; kavanoz.setColorFilter(getResources().getColor(R.color.green)); } } }); // ShakeDetector initialization mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mShakeDetector = new ShakeDetector(); mShakeDetector.setOnShakeListener(new ShakeDetector.OnShakeListener() { @Override public void onShake(int count) { if (shakemode) { /* * The following method, "handleShakeEvent(count):" is a stub // * method you would use to setup whatever you want done once the * device has been shook. */ // View element to be shaken // Perform animation Crashlytics.log("Shake event : triggered"); Answers.getInstance().logCustom(new CustomEvent("Shake event : tetiklendi")); kavanoz.startAnimation(shake); new rastgeletweet().execute(); } } }); } }
From source file:com.wanderingcan.persistentsearch.SearchMenuItem.java
/** * Sets the drawable for the icon for the SearchMenuItem * @param icon The drawable for the icon *//* www .ja va 2s .c om*/ 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; }