Search in sources :

Example 66 with ColorFilter

use of android.graphics.ColorFilter in project fresco by facebook.

the class DrawableTestUtils method stubGetPaint.

/**
 * Stubs getPaint for BitmapDrawables.
 *
 * @param drawable drawable to stub methods of
 */
public static void stubGetPaint(Drawable drawable) {
    if (!(drawable instanceof BitmapDrawable)) {
        return;
    }
    BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
    final Paint paint = new Paint();
    when(bitmapDrawable.getPaint()).thenReturn(paint);
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            paint.setColorFilter((ColorFilter) invocation.getArguments()[0]);
            return null;
        }
    }).when(bitmapDrawable).setColorFilter(any(ColorFilter.class));
}
Also used : Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) ColorFilter(android.graphics.ColorFilter) InvocationOnMock(org.mockito.invocation.InvocationOnMock) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Paint(android.graphics.Paint)

Example 67 with ColorFilter

use of android.graphics.ColorFilter in project fresco by facebook.

the class AnimationBackendDelegateTest method testForwardProperties.

@Test
public void testForwardProperties() {
    ColorFilter colorFilter = mock(ColorFilter.class);
    Rect bounds = mock(Rect.class);
    int alphaValue = 123;
    verifyZeroInteractions(mAnimationBackend);
    // Set values to be persisted
    mAnimationBackendDelegate.setAlpha(alphaValue);
    mAnimationBackendDelegate.setColorFilter(colorFilter);
    mAnimationBackendDelegate.setBounds(bounds);
    // Verify that values have been restored
    verify(mAnimationBackend).setAlpha(alphaValue);
    verify(mAnimationBackend).setColorFilter(colorFilter);
    verify(mAnimationBackend).setBounds(bounds);
}
Also used : Rect(android.graphics.Rect) ColorFilter(android.graphics.ColorFilter) Test(org.junit.Test)

Example 68 with ColorFilter

use of android.graphics.ColorFilter in project fresco by facebook.

the class HierarcherImpl method buildActualImageWrapper.

@Override
public ForwardingDrawable buildActualImageWrapper(ImageOptions imageOptions, @Nullable Object callerContext) {
    ScaleTypeDrawable wrapper = new ScaleTypeDrawable(NOP_DRAWABLE, imageOptions.getActualImageScaleType(), imageOptions.getActualImageFocusPoint());
    ColorFilter actualImageColorFilter = imageOptions.getActualImageColorFilter();
    if (actualImageColorFilter != null) {
        wrapper.setColorFilter(actualImageColorFilter);
    }
    return wrapper;
}
Also used : ColorFilter(android.graphics.ColorFilter) ScaleTypeDrawable(com.facebook.drawee.drawable.ScaleTypeDrawable)

Example 69 with ColorFilter

use of android.graphics.ColorFilter in project HomeMirror by HannahMitt.

the class MirrorActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mirror);
    mConfigSettings = new ConfigurationSettings(this);
    AlarmReceiver.startMirrorUpdates(this);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_IMMERSIVE;
        decorView.setSystemUiVisibility(uiOptions);
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();
    }
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mBirthdayText = (TextView) findViewById(R.id.birthday_text);
    mDayText = (TextView) findViewById(R.id.day_text);
    mWeatherSummary = (TextView) findViewById(R.id.weather_summary);
    mHelloText = (TextView) findViewById(R.id.hello_text);
    mWaterPlants = findViewById(R.id.water_plants);
    mGroceryList = findViewById(R.id.grocery_list);
    mBikeTodayText = (TextView) findViewById(R.id.can_bike);
    mStockText = (TextView) findViewById(R.id.stock_text);
    mMoodText = (TextView) findViewById(R.id.mood_text);
    mXKCDImage = (ImageView) findViewById(R.id.xkcd_image);
    mNewsHeadline = (TextView) findViewById(R.id.news_headline);
    mCalendarTitleText = (TextView) findViewById(R.id.calendar_title);
    mCalendarDetailsText = (TextView) findViewById(R.id.calendar_details);
    mCountdownText = (TextView) findViewById(R.id.countdown_text);
    if (mConfigSettings.invertXKCD()) {
        // Negative of XKCD image
        float[] colorMatrixNegative = { // red
        -1.0f, // red
        0, // red
        0, // red
        0, // red
        255, // green
        0, // green
        -1.0f, // green
        0, // green
        0, // green
        255, // blue
        0, // blue
        0, // blue
        -1.0f, // blue
        0, // blue
        255, // alpha
        0, // alpha
        0, // alpha
        0, // alpha
        1.0f, // alpha
        0 };
        ColorFilter colorFilterNegative = new ColorMatrixColorFilter(colorMatrixNegative);
        // not inverting for now
        mXKCDImage.setColorFilter(colorFilterNegative);
    }
    setViewState();
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ColorFilter(android.graphics.ColorFilter) ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ConfigurationSettings(com.morristaedt.mirror.configuration.ConfigurationSettings) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar)

Example 70 with ColorFilter

use of android.graphics.ColorFilter in project androidApp by InspectorIncognito.

the class OnBusEngine method setBusStopDrawable.

private void setBusStopDrawable() {
    ServiceHelper helper = new ServiceHelper(TranSappApplication.getAppContext());
    int colorId = helper.getColorId(bus.getService());
    int color = ContextCompat.getColor(TranSappApplication.getAppContext(), Constants.BUS_COLOR.get(colorId));
    Drawable iconDrawable = ContextCompat.getDrawable(TranSappApplication.getAppContext(), R.drawable.paradero).mutate();
    Bitmap bitmap = MapboxUtil.getBitmapFromDrawable(iconDrawable);
    Paint paint = new Paint();
    ColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY);
    paint.setColorFilter(filter);
    Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(mutableBitmap);
    canvas.drawBitmap(mutableBitmap, 0, 0, paint);
    mapboxMap.addImage("routeBusIcon", mutableBitmap);
}
Also used : Bitmap(android.graphics.Bitmap) ColorFilter(android.graphics.ColorFilter) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) ServiceHelper(cl.smartcities.isci.transportinspector.database.ServiceHelper) Paint(android.graphics.Paint)

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