use of android.graphics.drawable.StateListDrawable in project circular-progress-button by dmytrodanylyk.
the class CircularProgressButton method initErrorStateDrawable.
private void initErrorStateDrawable() {
int colorPressed = getPressedColor(mErrorColorState);
StrokeGradientDrawable drawablePressed = createDrawable(colorPressed);
mErrorStateDrawable = new StateListDrawable();
mErrorStateDrawable.addState(new int[] { android.R.attr.state_pressed }, drawablePressed.getGradientDrawable());
mErrorStateDrawable.addState(StateSet.WILD_CARD, background.getGradientDrawable());
}
use of android.graphics.drawable.StateListDrawable in project FlexibleAdapter by davideas.
the class FastScroller method setBubbleAndHandleColor.
private void setBubbleAndHandleColor(int accentColor) {
//TODO: Programmatically generate the Drawables instead of using resources
//BubbleDrawable accentColor
GradientDrawable bubbleDrawable;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
bubbleDrawable = (GradientDrawable) getResources().getDrawable(R.drawable.fast_scroller_bubble, null);
} else {
//noinspection deprecation
bubbleDrawable = (GradientDrawable) getResources().getDrawable(R.drawable.fast_scroller_bubble);
}
assert bubbleDrawable != null;
bubbleDrawable.setColor(accentColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
bubble.setBackground(bubbleDrawable);
} else {
//noinspection deprecation
bubble.setBackgroundDrawable(bubbleDrawable);
}
//HandleDrawable accentColor
try {
StateListDrawable stateListDrawable;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
stateListDrawable = (StateListDrawable) getResources().getDrawable(R.drawable.fast_scroller_handle, null);
} else {
//noinspection deprecation
stateListDrawable = (StateListDrawable) getResources().getDrawable(R.drawable.fast_scroller_handle);
}
//Method is still hidden, invoke Java reflection
Method getStateDrawable = StateListDrawable.class.getMethod("getStateDrawable", int.class);
GradientDrawable handleDrawable = (GradientDrawable) getStateDrawable.invoke(stateListDrawable, 0);
handleDrawable.setColor(accentColor);
handle.setImageDrawable(stateListDrawable);
} catch (Exception e) {
e.printStackTrace();
}
}
use of android.graphics.drawable.StateListDrawable in project GalleryFinal by pengjianbo.
the class FloatingActionButton method createFillDrawable.
private StateListDrawable createFillDrawable(RectF circleRect) {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[] { android.R.attr.state_pressed }, createCircleDrawable(circleRect, mColorPressed));
drawable.addState(new int[] {}, createCircleDrawable(circleRect, mColorNormal));
return drawable;
}
use of android.graphics.drawable.StateListDrawable in project android_frameworks_base by ResurrectionRemix.
the class RenderDrawable method render.
public Result render() {
checkLock();
// get the drawable resource value
DrawableParams params = getParams();
HardwareConfig hardwareConfig = params.getHardwareConfig();
ResourceValue drawableResource = params.getDrawable();
// resolve it
BridgeContext context = getContext();
drawableResource = context.getRenderResources().resolveResValue(drawableResource);
if (drawableResource == null) {
return Status.ERROR_NOT_A_DRAWABLE.createResult();
}
ResourceType resourceType = drawableResource.getResourceType();
if (resourceType != ResourceType.DRAWABLE && resourceType != ResourceType.MIPMAP) {
return Status.ERROR_NOT_A_DRAWABLE.createResult();
}
Drawable d = ResourceHelper.getDrawable(drawableResource, context);
final Boolean allStates = params.getFlag(RenderParamsFlags.FLAG_KEY_RENDER_ALL_DRAWABLE_STATES);
if (allStates == Boolean.TRUE) {
final List<BufferedImage> result;
if (d instanceof StateListDrawable) {
result = new ArrayList<BufferedImage>();
final StateListDrawable stateList = (StateListDrawable) d;
for (int i = 0; i < stateList.getStateCount(); i++) {
final Drawable stateDrawable = stateList.getStateDrawable(i);
result.add(renderImage(hardwareConfig, stateDrawable, context));
}
} else {
result = Collections.singletonList(renderImage(hardwareConfig, d, context));
}
return Status.SUCCESS.createResult(result);
} else {
BufferedImage image = renderImage(hardwareConfig, d, context);
return Status.SUCCESS.createResult(image);
}
}
use of android.graphics.drawable.StateListDrawable in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class FloatingActionButton method createFillDrawable.
private StateListDrawable createFillDrawable(float strokeWidth) {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[] { -android.R.attr.state_enabled }, createCircleDrawable(mColorDisabled, strokeWidth));
drawable.addState(new int[] { android.R.attr.state_pressed }, createCircleDrawable(mColorPressed, strokeWidth));
drawable.addState(new int[] {}, createCircleDrawable(mColorNormal, strokeWidth));
return drawable;
}
Aggregations