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));
}
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);
}
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;
}
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();
}
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);
}
Aggregations