Search in sources :

Example 1 with RotateDrawable

use of android.graphics.drawable.RotateDrawable in project little-bear-dictionary by daimajia.

the class ProgressBar method getDrawable.

// Very funny change android.RotateDrawable on custom RotateDrawable,
// ported from JB
private Drawable getDrawable(TypedArray a, int attr) {
    Drawable d = a.getDrawable(attr);
    try {
        int id = a.getResourceId(attr, 0);
        if ((id == R.drawable.progress_small_holo || id == R.drawable.progress_medium_holo || id == R.drawable.progress_large_holo) && VERSION.SDK_INT < 14) {
            LayerDrawable layers = (LayerDrawable) d;
            int layersCount = layers.getNumberOfLayers();
            Drawable[] newLayers = new Drawable[layersCount];
            for (int i = 0; i < layersCount; i++) {
                Drawable layer = layers.getDrawable(i);
                if (layer instanceof RotateDrawable && (i == 0 || i == 1)) {
                    org.holoeverywhere.drawable.RotateDrawable r = new org.holoeverywhere.drawable.RotateDrawable();
                    Drawable rotatedDrawable = ((RotateDrawable) layer).getDrawable();
                    if (i == 0) {
                        r.setState(rotatedDrawable, true, true, 0.5f, 0.5f, 0f, 1080f);
                    } else if (i == 1) {
                        r.setState(rotatedDrawable, true, true, 0.5f, 0.5f, 720f, 0f);
                    }
                    layer = r;
                }
                newLayers[i] = layer;
            }
            return new LayerDrawable(newLayers);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return d;
}
Also used : RotateDrawable(android.graphics.drawable.RotateDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) ClipDrawable(android.graphics.drawable.ClipDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RotateDrawable(android.graphics.drawable.RotateDrawable) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 AnimationDrawable (android.graphics.drawable.AnimationDrawable)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ClipDrawable (android.graphics.drawable.ClipDrawable)1 Drawable (android.graphics.drawable.Drawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 RotateDrawable (android.graphics.drawable.RotateDrawable)1 ShapeDrawable (android.graphics.drawable.ShapeDrawable)1 StateListDrawable (android.graphics.drawable.StateListDrawable)1