android.graphics.drawable.RotateDrawable Java Examples

The following examples show how to use android.graphics.drawable.RotateDrawable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utils.java    From BlackList with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the background color of the drawable
 **/
public static void setDrawableColor(Context context, Drawable drawable, @AttrRes int colorAttrRes) {
    int colorRes = getResourceId(context, colorAttrRes);
    int color = ContextCompat.getColor(context, colorRes);
    if (drawable instanceof ShapeDrawable) {
        ((ShapeDrawable) drawable).getPaint().setColor(color);
    } else if (drawable instanceof GradientDrawable) {
        ((GradientDrawable) drawable).setColor(color);
    } else if (drawable instanceof ColorDrawable) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            ((ColorDrawable) drawable).setColor(color);
        }
    } else if (drawable instanceof RotateDrawable) {
        setDrawableColor(context, ((RotateDrawable) drawable).getDrawable(), colorAttrRes);
    }
}
 
Example #2
Source File: InstaTag.java    From InstaTag with Apache License 2.0 6 votes vote down vote up
private void setColor(Drawable drawable, int color) {
    if (drawable instanceof ShapeDrawable) {
        ((ShapeDrawable) drawable).getPaint().setColor(color);
    } else if (drawable instanceof GradientDrawable) {
        ((GradientDrawable) drawable).setColor(color);
    } else if (drawable instanceof ColorDrawable) {
        ((ColorDrawable) drawable).setColor(color);
    } else if (drawable instanceof LayerDrawable) {
        LayerDrawable layerDrawable = (LayerDrawable) drawable;
        RotateDrawable rotateDrawable =
                (RotateDrawable) layerDrawable.findDrawableByLayerId(R.id.carrot_shape_top);
        setColor(rotateDrawable.getDrawable(), color);
    } else if (drawable instanceof RotateDrawable) {
        setColor(((RotateDrawable) drawable).getDrawable(), color);
    }
}
 
Example #3
Source File: ChatHolder.java    From FirebaseUI-Android with Apache License 2.0 6 votes vote down vote up
private void setIsSender(boolean isSender) {
    final int color;
    if (isSender) {
        color = mGreen300;
        mLeftArrow.setVisibility(View.GONE);
        mRightArrow.setVisibility(View.VISIBLE);
        mMessageContainer.setGravity(Gravity.END);
    } else {
        color = mGray300;
        mLeftArrow.setVisibility(View.VISIBLE);
        mRightArrow.setVisibility(View.GONE);
        mMessageContainer.setGravity(Gravity.START);
    }

    ((GradientDrawable) mMessage.getBackground()).setColor(color);
    ((RotateDrawable) mLeftArrow.getBackground()).getDrawable()
            .setColorFilter(color, PorterDuff.Mode.SRC);
    ((RotateDrawable) mRightArrow.getBackground()).getDrawable()
            .setColorFilter(color, PorterDuff.Mode.SRC);
}