/**
* Gets the icon with an applied color filter
* for the correct theme.
*
* @param context the context to use.
* @param res the drawable resource to use.
* @param dark true for icon suitable for use with a dark theme,
* false for icon suitable for use with a light theme.
* @return a themed icon.
*/
@NonNull
public static Bitmap getThemedBitmap(@NonNull Context context, @DrawableRes int res, boolean dark) {
int color = dark ? getIconDarkThemeColor(context) : getIconLightThemeColor(context);
Bitmap sourceBitmap = getBitmapFromVectorDrawable(context, res);
Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap.getWidth(), sourceBitmap.getHeight(),
Bitmap.Config.ARGB_8888);
Paint p = new Paint();
ColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
p.setColorFilter(filter);
Canvas canvas = new Canvas(resultBitmap);
canvas.drawBitmap(sourceBitmap, 0, 0, p);
sourceBitmap.recycle();
return resultBitmap;
}
java类android.graphics.ColorFilter的实例源码
ThemeUtils.java 文件源码
项目:Xndroid
阅读 42
收藏 0
点赞 0
评论 0
FolderAdapter.java 文件源码
项目:Hello-Music-droid
阅读 43
收藏 0
点赞 0
评论 0
public void applyTheme(boolean dark) {
ColorFilter cf = new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
for (Drawable d : mIcons) {
if (dark) {
d.setColorFilter(cf);
} else {
d.clearColorFilter();
}
}
}
CircleImageView.java 文件源码
项目:FastAndroid
阅读 49
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
applyColorFilter();
invalidate();
}
CircleImageView.java 文件源码
项目:MusicX-music-player
阅读 47
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
applyColorFilter();
invalidate();
}
CnSvgBigRenderer.java 文件源码
项目:ChinaMapInfoView
阅读 32
收藏 0
点赞 0
评论 0
private void renderGo(Canvas canvas, ColorFilter filter, Paint paint, int i) {
if (i >= 0 && i <= 8) {
renderByProvince1(i);
} else if (i >= 9 && i <= 19) {
renderByProvince2(i);
} else if (i >= 20 && i <= 29) {
renderByProvince3(i);
} else if (i >= 29 && i <= 33) {
renderByProvince4(i);
}
mRenderPath.addPath(mPath, mFinalPathMatrix);
paint.setStrokeJoin(Paint.Join.MITER);
paint.setStrokeCap(Paint.Cap.BUTT);
paint.setStrokeMiter(4.0f);
paint.setColorFilter(filter);
canvas.drawPath(mRenderPath, paint);
// Region
mRegion = mRegionList.get(i);
mRegion.setPath(mRenderPath, mGlobalRegion);
mRegionList.set(i, mRegion);
mPath.reset();
mRenderPath.reset();
mFinalPathMatrix.setValues(
new float[]{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}
);
mFinalPathMatrix.postScale(scaleX, scaleY);
}
AnimatedVectorDrawableCompat.java 文件源码
项目:boohee_v5.6
阅读 31
收藏 0
点赞 0
评论 0
public void setColorFilter(ColorFilter colorFilter) {
if (this.mDelegateDrawable != null) {
this.mDelegateDrawable.setColorFilter(colorFilter);
} else {
this.mAnimatedVectorState.mVectorDrawable.setColorFilter(colorFilter);
}
}
ApiCompatibilityUtils.java 文件源码
项目:chromium-net-for-android
阅读 38
收藏 0
点赞 0
评论 0
/**
* @see android.graphics.drawable.Drawable#getColorFilter().
*/
@SuppressWarnings("NewApi")
public static ColorFilter getColorFilter(Drawable drawable) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return drawable.getColorFilter();
} else {
return null;
}
}
AnimationBackendDelegate.java 文件源码
项目:GitHub
阅读 33
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter colorFilter) {
if (mAnimationBackend != null) {
mAnimationBackend.setColorFilter(colorFilter);
}
mColorFilter = colorFilter;
}
RotateCircleImageView.java 文件源码
项目:RotateCircleImageView
阅读 35
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
applyColorFilter();
invalidate();
}
DrawableUtilsTest.java 文件源码
项目:GitHub
阅读 60
收藏 0
点赞 0
评论 0
@Test
public void testSetDrawablePropertiesDefault() {
DrawableProperties properties = new DrawableProperties();
Drawable drawableTo = mock(Drawable.class);
DrawableUtils.setDrawableProperties(drawableTo, properties);
verify(drawableTo, never()).setAlpha(anyInt());
verify(drawableTo, never()).setColorFilter(any(ColorFilter.class));
verify(drawableTo, never()).setDither(anyBoolean());
verify(drawableTo, never()).setFilterBitmap(anyBoolean());
}
Alerter.java 文件源码
项目:Alerter
阅读 41
收藏 0
点赞 0
评论 0
/**
* Set the icon color for the Alert
*
* @param colorFilter ColorFilter
* @return This Alerter
*/
public Alerter setIconColorFilter(@NonNull final ColorFilter colorFilter) {
if (getAlert() != null) {
getAlert().setIconColorFilter(colorFilter);
}
return this;
}
AbsCornerImageView.java 文件源码
项目:Widgets
阅读 29
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
applyColorFilter();
invalidate();
}
CircleImageView.java 文件源码
项目:AndroidSkinAnimator
阅读 39
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
applyColorFilter();
invalidate();
}
DrawableWrapper.java 文件源码
项目:revolution-irc
阅读 32
收藏 0
点赞 0
评论 0
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public ColorFilter getColorFilter() {
return mDrawable.getColorFilter();
}
MaterialProgressDrawable.java 文件源码
项目:ucar-weex-core
阅读 42
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter colorFilter) {
mRing.setColorFilter(colorFilter);
}
MaterialProgressDrawable.java 文件源码
项目:SmartRefreshLayout
阅读 30
收藏 0
点赞 0
评论 0
public void setColorFilter(ColorFilter filter) {
mPaint.setColorFilter(filter);
invalidateSelf();
}
StateDrawable.java 文件源码
项目:SliderPreferenceEmbedded
阅读 29
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
mPaint.setColorFilter(cf);
}
RoundRectDrawableWithShadow.java 文件源码
项目:Hitalk
阅读 32
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
mPaint.setColorFilter(cf);
mCornerShadowPaint.setColorFilter(cf);
mEdgeShadowPaint.setColorFilter(cf);
}
SVGBuilder.java 文件源码
项目:iosched-reader
阅读 33
收藏 0
点赞 0
评论 0
/**
* Applies a {@link ColorFilter} to the paint objects used to render the SVG.
*/
public SVGBuilder setColorFilter(ColorFilter colorFilter) {
this.strokeColorFilter = this.fillColorFilter = colorFilter;
return this;
}
EmojiProvider.java 文件源码
项目:Nird2
阅读 37
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(@Nullable ColorFilter cf) {
}
RoundDrawable.java 文件源码
项目:jackknife
阅读 29
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
mPaint.setColorFilter(cf);
}
RoundedDrawable.java 文件源码
项目:shareNote
阅读 35
收藏 0
点赞 0
评论 0
@Override
public ColorFilter getColorFilter() {
return mBitmapPaint.getColorFilter();
}
CollisionLoadingRenderer.java 文件源码
项目:GitHub
阅读 28
收藏 0
点赞 0
评论 0
@Override
protected void setColorFilter(ColorFilter cf) {
mPaint.setColorFilter(cf);
}
QMUIViewHelper.java 文件源码
项目:qmui
阅读 40
收藏 0
点赞 0
评论 0
public static ColorFilter setImageViewTintColor(ImageView imageView, @ColorInt int tintColor) {
LightingColorFilter colorFilter = new LightingColorFilter(Color.argb(255, 0, 0, 0), tintColor);
imageView.setColorFilter(colorFilter);
return colorFilter;
}
ProgressDrawable.java 文件源码
项目:android_ui
阅读 30
收藏 0
点赞 0
评论 0
/**
*/
@Override
public void setColorFilter(ColorFilter colorFilter) {
PAINT.setColorFilter(colorFilter);
}
BorderDrawable.java 文件源码
项目:ucar-weex-core
阅读 29
收藏 0
点赞 0
评论 0
/**
* Do not support Color Filter
*/
@Override
public void setColorFilter(ColorFilter cf) {
}
LauncherIconDrawable.java 文件源码
项目:DreamDrawable
阅读 32
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
if (mDrawable != null) {
mDrawable.setColorFilter(cf);
}
}
Region.java 文件源码
项目:style-transfer
阅读 31
收藏 0
点赞 0
评论 0
public Drawable findMatch(ScriptC_find_region findRegion, RenderScript mRs, Bitmap image) {
Rect mRoiBounds = mFindRegion.findMatch(findRegion, mRs, image);
int cutOffsetX = mFindRegion.getCutOffsetX();
int cutOffsetY = mFindRegion.getCutOffsetY();
final Path path = new Path();
for (int i = 0; i < mPointsXY.length; i += 2) {
if (i == 0) {
path.moveTo(mPointsXY[i] - mRoiBounds.left + cutOffsetX,
mPointsXY[i + 1] - mRoiBounds.top + cutOffsetY);
} else {
path.lineTo(mPointsXY[i] - mRoiBounds.left + cutOffsetX,
mPointsXY[i + 1] - mRoiBounds.top + cutOffsetY);
}
}
path.close();
Drawable d = new Drawable() {
Paint paint = new Paint();
{
paint.setStyle(Paint.Style.STROKE);
}
@Override
public void draw(Canvas canvas) {
canvas.drawPath(path, paint);
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter cf) {
}
@Override
public int getOpacity() {
return 0;
}
};
return d;
}
RoundedDrawable.java 文件源码
项目:shareNote
阅读 39
收藏 0
点赞 0
评论 0
@Override
public void setColorFilter(ColorFilter cf) {
mBitmapPaint.setColorFilter(cf);
invalidateSelf();
}
CoolWaitLoadingRenderer.java 文件源码
项目:GitHub
阅读 36
收藏 0
点赞 0
评论 0
@Override
protected void setColorFilter(ColorFilter cf) {
mPaint.setColorFilter(cf);
}