create RainbowSpan effect

public class RainbowSpan extends CharacterStyle implements UpdateAppearance {
    private final int[] colors;

    public RainbowSpan(Context context) {
        colors = new int[]{
                Color.parseColor("#FF0033"),
                Color.parseColor("#FF8000"),
                Color.parseColor("#FFE600"),
                Color.parseColor("#1AB34D"),
                Color.parseColor("#1A66FF"),
                Color.parseColor("#801AB3")
        };
    }

    @Override
    public void updateDrawState(TextPaint paint) {
        paint.setStyle(Paint.Style.FILL);
        Shader shader = new LinearGradient(
                0, 0, 0,
                paint.getTextSize() * colors.length,
                colors, null,
                Shader.TileMode.MIRROR);
        Matrix matrix = new Matrix();
        matrix.setRotate(90);
        shader.setLocalMatrix(matrix);
        paint.setShader(shader);
    }
}

Better style for stackoverflow front page – grasemonkey script

Zrzut ekranu 2015-01-26 10.29.45

Here is script for better front page style.

[javascript]
// ==UserScript==
// @name Better style for stackoverflow front page
// @namespace
// @description changes background of front page and interesting items
// @include *stackoverflow.com*
// @version 1
// @grant GM_addStyle
// ==/UserScript==
document.body.style.background = “#f0f0f0”;
GM_addStyle(‘.tagged-interesting {background-color:#f5f5f5; padding:5px}’);
[/javascript]

Smaller ratingboard with clickable area

During my one day project for a client I had to use (I hate it) android’s ratingbar component. One of the pointed task in project was to use a bit smaller object with 5 stars than it is as default. What is more it had to be place it in every item in listview.
So what’s the problem? “All you have to do is to use param

style="?"

” – I thought. But it has not been the final solution yet..

Continue reading “Smaller ratingboard with clickable area”