Search in sources :

Example 71 with ColorFilter

use of android.graphics.ColorFilter in project ElasticDownload by Tibolte.

the class VectorDrawable method draw.

@Override
public void draw(Canvas canvas) {
    final Rect bounds = getBounds();
    if (bounds.width() == 0 || bounds.height() == 0) {
        // too small to draw
        return;
    }
    final int saveCount = canvas.save();
    final boolean needMirroring = needMirroring();
    canvas.translate(bounds.left, bounds.top);
    if (needMirroring) {
        canvas.translate(bounds.width(), 0);
        canvas.scale(-1.0f, 1.0f);
    }
    // Color filters always override tint filters.
    final ColorFilter colorFilter = mColorFilter == null ? mTintFilter : mColorFilter;
    if (!mAllowCaching) {
        // AnimatedVectorDrawable
        if (!mVectorState.hasTranslucentRoot()) {
            mVectorState.mVPathRenderer.draw(canvas, bounds.width(), bounds.height(), colorFilter);
        } else {
            mVectorState.createCachedBitmapIfNeeded(bounds);
            mVectorState.updateCachedBitmap(bounds);
            mVectorState.drawCachedBitmapWithRootAlpha(canvas, colorFilter);
        }
    } else {
        // Static Vector Drawable case.
        mVectorState.createCachedBitmapIfNeeded(bounds);
        if (!mVectorState.canReuseCache()) {
            mVectorState.updateCachedBitmap(bounds);
            mVectorState.updateCacheStates();
        }
        mVectorState.drawCachedBitmapWithRootAlpha(canvas, colorFilter);
    }
    canvas.restoreToCount(saveCount);
}
Also used : Rect(android.graphics.Rect) ColorFilter(android.graphics.ColorFilter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint)

Example 72 with ColorFilter

use of android.graphics.ColorFilter in project AndroidChromium by JackyAndroid.

the class CardUnmaskPrompt method setInputError.

/**
 * Sets the error message on the cvc input.
 * @param message The error message to show, or null if the error state should be cleared.
 */
private void setInputError(String message) {
    mErrorMessage.setText(message);
    mErrorMessage.setVisibility(message == null ? View.GONE : View.VISIBLE);
    // Announcing twice in a row may cancel the first announcement.
    if (message != null) {
        mErrorMessage.announceForAccessibility(message);
    }
    // draw the TextInput.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        return;
    ColorFilter filter = null;
    if (message != null) {
        filter = new PorterDuffColorFilter(ApiCompatibilityUtils.getColor(mDialog.getContext().getResources(), R.color.input_underline_error_color), PorterDuff.Mode.SRC_IN);
    }
    // TODO(estade): it would be nicer if the error were specific enough to tell us which input
    // was invalid.
    updateColorForInput(mCardUnmaskInput, filter);
    updateColorForInput(mMonthInput, filter);
    updateColorForInput(mYearInput, filter);
}
Also used : ColorFilter(android.graphics.ColorFilter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter)

Example 73 with ColorFilter

use of android.graphics.ColorFilter in project Slide by ccrama.

the class BlendModeUtil method tintPaint.

private static void tintPaint(@NonNull final Paint paint, @ColorInt final int color, final BlendModeCompat mode) {
    final ColorFilter filter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, mode);
    paint.setColorFilter(filter);
}
Also used : ColorFilter(android.graphics.ColorFilter)

Example 74 with ColorFilter

use of android.graphics.ColorFilter in project Slide by ccrama.

the class BlendModeUtil method tintImageView.

private static void tintImageView(@NonNull final ImageView imageView, @ColorInt final int color, final BlendModeCompat mode) {
    final ColorFilter filter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, mode);
    imageView.setColorFilter(filter);
}
Also used : ColorFilter(android.graphics.ColorFilter)

Example 75 with ColorFilter

use of android.graphics.ColorFilter in project Slide by ccrama.

the class BlendModeUtil method tintDrawable.

private static void tintDrawable(@NonNull final Drawable drawable, @ColorInt final int color, final BlendModeCompat mode) {
    final ColorFilter filter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(color, mode);
    drawable.setColorFilter(filter);
}
Also used : ColorFilter(android.graphics.ColorFilter)

Aggregations

ColorFilter (android.graphics.ColorFilter)75 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)26 LightingColorFilter (android.graphics.LightingColorFilter)25 Paint (android.graphics.Paint)25 Drawable (android.graphics.drawable.Drawable)23 Canvas (android.graphics.Canvas)14 FilterableStateListDrawable (com.simplecity.amp_library.ui.views.FilterableStateListDrawable)14 LayerDrawable (android.graphics.drawable.LayerDrawable)12 Bitmap (android.graphics.Bitmap)11 View (android.view.View)7 Test (org.junit.Test)7 Path (android.graphics.Path)5 Rect (android.graphics.Rect)5 RectF (android.graphics.RectF)5 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 Animator (android.animation.Animator)3 SuppressLint (android.annotation.SuppressLint)3 Intent (android.content.Intent)3