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;
}
Aggregations