Hi,
I am trying to store drawables in a static SoftReferenceMap for a ListView containing progress-bars in every row. Every row has a different progress, but when I set it through setProgress(int) all rows get affected.
I tried doing mDrawable.mutate().setLevel(progress*10000/max), but it still doesn't work.
public void setProgres(int status, int progress, int max) {
Drawable d = getDrawable(status);
switch (status) {
case RED_INDETERMINATE:
setIndeterminateDrawable(d);
setIndeterminate(true);
break;
case YELLOW:
d.mutate().setLevel((int) (progress * 10000 / max));
case GREEN:
case BLUE:
setProgressDrawable(d);
break;
default:
throw new IllegalArgumentException(
"Invalid Status setting for ArtooProgressBar: " + status);
}
getProgressDrawable().invalidateSelf();
super.invalidate();
}
private Drawable getDrawable(int status) {
SoftReference<Drawable> ref = sDrawableMaps.get("" + status);
if (ref != null && ref.get() != null)
return ref.get();
Drawable d;
switch (status) {
case RED_INDETERMINATE:
d = getResources().getDrawable(
R.drawable.progress_bar_indeterminate);
d = tileifyIndeterminate(d);
break;
case YELLOW:
// d = yellow;
d = getResources().getDrawable(
R.drawable.progress_bar_determinate_yellow);
break;
case GREEN:
d = getResources().getDrawable(
R.drawable.progress_bar_determinate_green);
d.setLevel(10000);
break;
case BLUE:
d = getResources().getDrawable(
R.drawable.progress_bar_determinate_blue);
d.setLevel(10000);
break;
default:
throw new IllegalArgumentException(
"Invalid Status setting for ArtooProgressBar: " + status);
}
if (d != null)
sDrawableMaps.put("" + status, new SoftReference<Drawable>(d));
d.invalidateSelf();
return d;
}
What am I missing?
Thanks