Methods Summary |
---|
public void | applyFilterToView(android.view.View view)Apply current the ColorFilter to a View. This method will set the
hardware layer of the view when applying a filter, and remove it when not
applying a filter.
if (mFilter != null) {
view.setLayerType(View.LAYER_TYPE_HARDWARE, mPaint);
} else {
view.setLayerType(View.LAYER_TYPE_NONE, null);
}
// FIXME: Current framework has bug that not triggering invalidate when change layer
// paint. Will add conditional sdk version check once bug is fixed in released
// framework.
view.invalidate();
|
public static android.support.v17.leanback.graphics.ColorFilterDimmer | create(ColorFilterCache dimmer, float activeLevel, float dimmedLevel)Creates a ColorFilterDimmer for the given color and levels..
return new ColorFilterDimmer(dimmer, activeLevel, dimmedLevel);
|
public static android.support.v17.leanback.graphics.ColorFilterDimmer | createDefault(android.content.Context context)Creates a default ColorFilterDimmer. Uses the default color and level for
the dimmer.
TypedArray a = context.obtainStyledAttributes(R.styleable.LeanbackTheme);
int dimColor = a.getColor(R.styleable.LeanbackTheme_overlayDimMaskColor,
context.getResources().getColor(R.color.lb_view_dim_mask_color));
float activeLevel = a.getFraction(R.styleable.LeanbackTheme_overlayDimActiveLevel, 1, 1,
context.getResources().getFraction(R.fraction.lb_view_active_level, 1, 0));
float dimmedLevel = a.getFraction(R.styleable.LeanbackTheme_overlayDimDimmedLevel, 1, 1,
context.getResources().getFraction(R.fraction.lb_view_dimmed_level, 1, 1));
a.recycle();
return new ColorFilterDimmer(ColorFilterCache.getColorFilterCache(
dimColor), activeLevel, dimmedLevel);
|
public android.graphics.ColorFilter | getColorFilter()Gets the ColorFilter set to the current dim level.
return mFilter;
|
public android.graphics.Paint | getPaint()Gets the Paint object set to the current dim level.
return mPaint;
|
public void | setActiveLevel(float level)Sets the active level of the dimmer. Updates the ColorFilter based on the
level.
if (level < 0.0f) level = 0.0f;
if (level > 1.0f) level = 1.0f;
mFilter = mColorDimmer.getFilterForLevel(
mDimmedLevel + level * (mActiveLevel - mDimmedLevel));
mPaint.setColorFilter(mFilter);
|